1991-09-03 15:11:18 +00:00
|
|
|
#include <lib.h>
|
|
|
|
#define fcntl _fcntl
|
|
|
|
#include <fcntl.h>
|
1991-09-19 12:54:23 +00:00
|
|
|
#if _ANSI
|
|
|
|
#endif
|
1991-09-03 15:11:18 +00:00
|
|
|
|
|
|
|
#if _ANSI
|
1991-09-19 12:54:23 +00:00
|
|
|
#include <stdarg.h>
|
1991-09-03 15:11:18 +00:00
|
|
|
PUBLIC int fcntl(int fd, int cmd, ...)
|
1991-09-19 12:54:23 +00:00
|
|
|
{
|
1991-09-03 15:11:18 +00:00
|
|
|
#else
|
1991-09-19 12:54:23 +00:00
|
|
|
#include <varargs.h>
|
|
|
|
PUBLIC int fcntl(va_alist)
|
|
|
|
va_dcl
|
|
|
|
{
|
1991-09-03 15:11:18 +00:00
|
|
|
int fd;
|
|
|
|
int cmd;
|
|
|
|
#endif
|
1991-09-19 12:54:23 +00:00
|
|
|
va_list ap;
|
1991-09-03 15:11:18 +00:00
|
|
|
int int3; /* third integer parameter for callm1 */
|
|
|
|
char *ptr1; /* first pointer parameter for callm1 */
|
|
|
|
|
1991-09-19 12:54:23 +00:00
|
|
|
#if _ANSI
|
|
|
|
va_start(ap, cmd);
|
|
|
|
#else
|
|
|
|
va_start(ap);
|
|
|
|
fd = va_arg(ap, int);
|
|
|
|
cmd = va_arg(ap, int);
|
|
|
|
#endif
|
1991-09-03 15:11:18 +00:00
|
|
|
|
|
|
|
/* Set up for the sensible case where there is no variable parameter. This
|
|
|
|
* covers F_GETFD, F_GETFL and invalid commands.
|
|
|
|
*/
|
|
|
|
int3 = 0;
|
|
|
|
ptr1 = NIL_PTR;
|
|
|
|
|
|
|
|
/* Adjust for the stupid cases. */
|
|
|
|
switch(cmd) {
|
|
|
|
case F_DUPFD:
|
|
|
|
case F_SETFD:
|
|
|
|
case F_SETFL:
|
1991-09-19 12:54:23 +00:00
|
|
|
int3 = va_arg(ap, int);
|
1991-09-03 15:11:18 +00:00
|
|
|
break;
|
|
|
|
case F_GETLK:
|
|
|
|
case F_SETLK:
|
|
|
|
case F_SETLKW:
|
1991-09-19 12:54:23 +00:00
|
|
|
ptr1 = (char *) va_arg(ap, struct flock *);
|
1991-09-03 15:11:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clean up and make the system call. */
|
1991-09-19 12:54:23 +00:00
|
|
|
va_end(ap);
|
1991-09-03 15:11:18 +00:00
|
|
|
return(_callm1(FS, FCNTL, fd, cmd, int3, ptr1, NIL_PTR, NIL_PTR));
|
|
|
|
}
|