--- os2sdk/demos/examples/argument/argument.c 2018/08/09 12:25:13 1.1 +++ os2sdk/demos/examples/argument/argument.c 2018/08/09 12:26:15 1.1.1.2 @@ -19,30 +19,35 @@ * compiled in. KNOW YOUR C STACK STRUCTURE! * * Many of the C runtime library routines, including printf, are not - * re-entrant. DOSENTERCRITSEC & DOSEXITCRITSEC guarantee serial access + * re-entrant. DosEnterCritSec & DosExitCritSec guarantee serial access * to the screen. * + * Created by Microsoft Corp. 1988 */ -#include + +#define INCL_DOSPROCESS + +#include +#include #include -#define STACK_SIZE 256 /* stack size in WORDS (see malloc) */ +#define STACK_SIZE 512 /* stack size in WORDS (see malloc) */ main(ac, av) char *av[]; int ac; { void far thread(); /* address where thread gets control */ - int far *threadStack; /* far pointer to thread stack (word)*/ - unsigned threadID; /* thread ID */ + PINT threadStack; /* far pointer to thread stack (word)*/ + TID threadID; /* thread ID */ unsigned rc; /* return code */ /* allocate stack space for thread */ - /* since this is written in C, DOSALLOCSEG cannot be used here */ + /* since this is written in C, DosAllocSeg cannot be used here */ if ((threadStack = (int *)malloc(sizeof(int) * STACK_SIZE)) == NULL) { printf("thread stack malloc failed\n"); - DOSEXIT(1, 1); /* terminate all threads and return error */ + DosExit(1, 1); /* terminate all threads and return error */ } threadStack += STACK_SIZE; /* since stack grows down */ @@ -52,16 +57,16 @@ int ac; *--threadStack = 0xCCCC; *--threadStack = 0xBBBB; - if (rc = DOSCREATETHREAD(thread, (unsigned far *)&threadID, - (char far *)threadStack)) { + if (rc = DosCreateThread(thread, &threadID, + (PBYTE)threadStack)) { printf("create of thread failed, error: %d\n", rc); - DOSEXIT(1, 1); + DosExit(1, 1); } - DOSENTERCRITSEC(); + DosEnterCritSec(); printf("Thread ID = %d\n", threadID); - DOSEXITCRITSEC(); + DosExitCritSec(); - DOSEXIT(0, 0); /* Terminate, Let the other thread run */ + DosExit(0, 0); /* Terminate, Let the other thread run */ } @@ -73,25 +78,25 @@ void far thread(a1,a2,a3,a4,a5) int a1,a2,a3,a4,a5; { - DOSENTERCRITSEC(); + DosEnterCritSec(); printf("Argument 1 = %x\n", a1); - DOSEXITCRITSEC(); + DosExitCritSec(); - DOSENTERCRITSEC(); + DosEnterCritSec(); printf("Argument 2 = %x\n", a2); - DOSEXITCRITSEC(); + DosExitCritSec(); - DOSENTERCRITSEC(); + DosEnterCritSec(); printf("Argument 3 = %x\n", a3); - DOSEXITCRITSEC(); + DosExitCritSec(); - DOSENTERCRITSEC(); + DosEnterCritSec(); printf("Argument 4 = %x\n", a4); - DOSEXITCRITSEC(); + DosExitCritSec(); - DOSENTERCRITSEC(); + DosEnterCritSec(); printf("Argument 5 = %x\n", a5); - DOSEXITCRITSEC(); + DosExitCritSec(); - DOSEXIT(0,0); + DosExit(0,0); }