#include <afsconfig.h>
#include <afs/param.h>
-
-#include <stdlib.h>
-#include <stdio.h>
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <time.h>
+#include <roken.h>
/* allocate externs here */
#define LWP_KERNEL
#include "lwp.h"
+
#ifdef AFS_AIX32_ENV
#include <ulimit.h>
#include <sys/errno.h>
#pragma alloca
int setlim(int limcon, uchar_t hard, int limit);
#endif
-#ifdef AFS_SGI64_ENV
-extern char *getenv();
-#include <time.h>
-#endif
-#include <string.h>
#ifndef AFS_ARM_LINUX20_ENV
-#if defined(AFS_OSF_ENV) || defined(AFS_S390_LINUX20_ENV)
-extern int PRE_Block; /* from preempt.c */
+#if defined(AFS_S390_LINUX20_ENV)
+int PRE_Block; /* Remnants of preemption support. */
#else
-extern char PRE_Block; /* from preempt.c */
+char PRE_Block; /* Remnants of preemption support. */
#endif
#endif
/* Throw away all dead process control blocks */
purge_dead_pcbs();
if (lwp_init) {
- temp = (PROCESS) malloc(sizeof(struct lwp_pcb));
+ temp = malloc(sizeof(struct lwp_pcb));
if (temp == NULL) {
Set_LWP_RC();
return LWP_ENOMEM;
stackmemory = stackptr;
#else
#ifdef AFS_DARWIN_ENV
- if ((stackmemory = (char *)malloc(stacksize + STACK_ALIGN - 1)) == NULL)
+ if ((stackmemory = malloc(stacksize + STACK_ALIGN - 1)) == NULL)
#else /* !AFS_DARWIN_ENV */
- if ((stackmemory = (char *)malloc(stacksize + 7)) == NULL)
+ if ((stackmemory = malloc(stacksize + 7)) == NULL)
#endif /* !AFS_DARWIN_ENV */
{
+ free(temp);
Set_LWP_RC();
return LWP_ENOMEM;
}
#endif /* !AFS_DARWIN_ENV */
#endif
if (priority < 0 || priority >= MAX_PRIORITIES) {
+ free(temp);
+ free(stackmemory);
Set_LWP_RC();
return LWP_EBADPRI;
}
/* Throw away all dead process control blocks */
purge_dead_pcbs();
if (lwp_init) {
- temp = (PROCESS) malloc(sizeof(struct lwp_pcb));
+ temp = malloc(sizeof(struct lwp_pcb));
if (temp == NULL) {
Set_LWP_RC();
return LWP_ENOMEM;
else
stacksize =
STACK_ALIGN * ((stacksize + STACK_ALIGN - 1) / STACK_ALIGN);
- if ((stackptr = (char *)malloc(stacksize)) == NULL) {
+ if ((stackptr = malloc(stacksize)) == NULL) {
Set_LWP_RC();
return LWP_ENOMEM;
}
blocked.count = 0;
qwaiting.head = NULL;
qwaiting.count = 0;
- lwp_init = (struct lwp_ctl *)malloc(sizeof(struct lwp_ctl));
- temp = (PROCESS) malloc(sizeof(struct lwp_pcb));
+ lwp_init = malloc(sizeof(struct lwp_ctl));
+ temp = malloc(sizeof(struct lwp_pcb));
if (lwp_init == NULL || temp == NULL)
Abort_LWP("Insufficient Storage to Initialize LWP Support");
LWPANCHOR.processcnt = 1;
}
if (ecount > lwp_cpptr->eventlistsize) {
- lwp_cpptr->eventlist =
- (void **)realloc(lwp_cpptr->eventlist,
- ecount * sizeof(void *));
+ lwp_cpptr->eventlist = realloc(lwp_cpptr->eventlist,
+ ecount * sizeof(void *));
lwp_cpptr->eventlistsize = ecount;
}
for (i = 0; i < ecount; i++)
currenttime = time(0);
timeStamp = ctime(¤ttime);
timeStamp[24] = 0;
- write(2, timeStamp, strlen(timeStamp));
-
- write(2, msg1, strlen(msg1));
- write(2, lwp_cpptr->name, strlen(lwp_cpptr->name));
- write(2, msg2, strlen(msg2));
+ if (write(2, timeStamp, strlen(timeStamp)) < 0)
+ return;
+
+ if (write(2, msg1, strlen(msg1)) < 0)
+ return;
+ if (write(2, lwp_cpptr->name, strlen(lwp_cpptr->name)) < 0)
+ return;
+ if (write(2, msg2, strlen(msg2)) < 0)
+ return;
}
static void
i++;
temp->name[31] = '\0';
temp->status = READY;
- temp->eventlist = (void **)malloc(EVINITSIZE * sizeof(void *));
+ temp->eventlist = malloc(EVINITSIZE * sizeof(void *));
temp->eventlistsize = EVINITSIZE;
temp->eventcnt = 0;
temp->wakevent = 0;