summaryrefslogtreecommitdiff
path: root/missing
diff options
context:
space:
mode:
Diffstat (limited to 'missing')
-rw-r--r--missing/alloca.c5
-rw-r--r--missing/dir.h65
-rw-r--r--missing/flock.c120
-rw-r--r--missing/hypot.c17
-rw-r--r--missing/strftime.c6
-rw-r--r--missing/vsnprintf.c6
6 files changed, 78 insertions, 141 deletions
diff --git a/missing/alloca.c b/missing/alloca.c
index 6879618c8a..5746497371 100644
--- a/missing/alloca.c
+++ b/missing/alloca.c
@@ -2,7 +2,6 @@
last edit: 86/05/30 rms
include config.h, since on VMS it renames some symbols.
- Use xmalloc instead of malloc.
This implementation of the PWB library alloca() function,
which is used to allocate space off the run-time stack so
@@ -53,7 +52,7 @@ typedef char *pointer; /* generic pointer type */
#define NULL 0 /* null pointer constant */
extern void free();
-extern pointer xmalloc();
+extern pointer malloc();
/*
Define STACK_DIRECTION if you know the direction of stack
@@ -173,7 +172,7 @@ alloca (size) /* returns pointer to storage */
/* Allocate combined header + user data storage. */
{
- register pointer new = xmalloc (sizeof (header) + size);
+ register pointer new = malloc (sizeof (header) + size);
/* address of header */
((header *)new)->h.next = last_alloca_header;
diff --git a/missing/dir.h b/missing/dir.h
deleted file mode 100644
index 830239b3ea..0000000000
--- a/missing/dir.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/* $RCSfile: dir.h,v $$Revision: 4.0.1.1 $$Date: 91/06/07 11:22:10 $
- *
- * (C) Copyright 1987, 1990 Diomidis Spinellis.
- *
- * You may distribute under the terms of either the GNU General Public
- * License or the Artistic License, as specified in the README file.
- *
- * $Log: dir.h,v $
- * Revision 4.0.1.1 91/06/07 11:22:10 lwall
- * patch4: new copyright notice
- *
- * Revision 4.0 91/03/20 01:34:20 lwall
- * 4.0 baseline.
- *
- * Revision 3.0.1.1 90/03/27 16:07:08 lwall
- * patch16: MSDOS support
- *
- * Revision 1.1 90/03/18 20:32:29 dds
- * Initial revision
- *
- *
- */
-
-/*
- * defines the type returned by the directory(3) functions
- */
-
-#ifndef __DIR_INCLUDED
-#define __DIR_INCLUDED
-
-#if !defined __MINGW32__
-/*Directory entry size */
-#ifdef DIRSIZ
-#undef DIRSIZ
-#endif
-#define DIRSIZ(rp) (sizeof(struct direct))
-
-/*
- * Structure of a directory entry
- */
-struct direct {
- ino_t d_ino; /* inode number (not used by MS-DOS) */
- int d_namlen; /* Name length */
- char d_name[256]; /* file name */
-};
-
-struct _dir_struc { /* Structure used by dir operations */
- char *start; /* Starting position */
- char *curr; /* Current position */
- long size; /* Size of string table */
- long nfiles; /* number if filenames in table */
- struct direct dirstr; /* Directory structure to return */
-};
-
-typedef struct _dir_struc DIR; /* Type returned by dir operations */
-
-DIR *cdecl opendir(char *filename);
-struct direct *readdir(DIR *dirp);
-long telldir(DIR *dirp);
-void seekdir(DIR *dirp,long loc);
-void rewinddir(DIR *dirp);
-void closedir(DIR *dirp);
-
-#endif
-#endif /* __DIR_INCLUDED */
diff --git a/missing/flock.c b/missing/flock.c
index 78576d438c..c828fcc7ad 100644
--- a/missing/flock.c
+++ b/missing/flock.c
@@ -1,6 +1,55 @@
#include "config.h"
-#if defined(HAVE_LOCKF)
+#if defined HAVE_FCNTL && defined HAVE_FCNTL_H
+
+/* These are the flock() constants. Since this sytems doesn't have
+ flock(), the values of the constants are probably not available.
+*/
+# ifndef LOCK_SH
+# define LOCK_SH 1
+# endif
+# ifndef LOCK_EX
+# define LOCK_EX 2
+# endif
+# ifndef LOCK_NB
+# define LOCK_NB 4
+# endif
+# ifndef LOCK_UN
+# define LOCK_UN 8
+# endif
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+int
+flock(fd, operation)
+ int fd;
+ int operation;
+{
+ struct flock lock;
+
+ switch (operation & ~LOCK_NB) {
+ case LOCK_SH:
+ lock.l_type = F_RDLCK;
+ break;
+ case LOCK_EX:
+ lock.l_type = F_WRLCK;
+ break;
+ case LOCK_UN:
+ lock.l_type = F_UNLCK;
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ lock.l_whence = SEEK_SET;
+ lock.l_start = lock.l_len = 0L;
+
+ return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &lock);
+}
+
+#elif defined(HAVE_LOCKF)
#include <unistd.h>
#include <errno.h>
@@ -45,86 +94,33 @@ flock(fd, operation)
int fd;
int operation;
{
- int i;
switch (operation) {
/* LOCK_SH - get a shared lock */
case LOCK_SH:
+ rb_notimplement();
+ return -1;
/* LOCK_EX - get an exclusive lock */
case LOCK_EX:
- i = lockf (fd, F_LOCK, 0);
- break;
+ return lockf (fd, F_LOCK, 0);
/* LOCK_SH|LOCK_NB - get a non-blocking shared lock */
case LOCK_SH|LOCK_NB:
+ rb_notimplement();
+ return -1;
/* LOCK_EX|LOCK_NB - get a non-blocking exclusive lock */
case LOCK_EX|LOCK_NB:
- i = lockf (fd, F_TLOCK, 0);
- if (i == -1)
- if ((errno == EAGAIN) || (errno == EACCES))
- errno = EWOULDBLOCK;
- break;
+ return lockf (fd, F_TLOCK, 0);
/* LOCK_UN - unlock */
case LOCK_UN:
- i = lockf (fd, F_ULOCK, 0);
- break;
+ return lockf (fd, F_ULOCK, 0);
/* Default - can't decipher operation */
default:
- i = -1;
errno = EINVAL;
- break;
+ return -1;
}
- return i;
-}
-#elif defined HAVE_FCNTL && defined HAVE_FCNTL_H
-
-/* These are the flock() constants. Since this sytems doesn't have
- flock(), the values of the constants are probably not available.
-*/
-# ifndef LOCK_SH
-# define LOCK_SH 1
-# endif
-# ifndef LOCK_EX
-# define LOCK_EX 2
-# endif
-# ifndef LOCK_NB
-# define LOCK_NB 4
-# endif
-# ifndef LOCK_UN
-# define LOCK_UN 8
-# endif
-
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
-int
-flock(fd, operation)
- int fd;
- int operation;
-{
- struct flock lock;
-
- switch (operation & ~LOCK_NB) {
- case LOCK_SH:
- lock.l_type = F_RDLCK;
- break;
- case LOCK_EX:
- lock.l_type = F_WRLCK;
- break;
- case LOCK_UN:
- lock.l_type = F_UNLCK;
- break;
- default:
- errno = EINVAL;
- return -1;
- }
- lock.l_whence = SEEK_SET;
- lock.l_start = lock.l_len = 0L;
-
- return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &lock);
}
#elif !defined NT
int
diff --git a/missing/hypot.c b/missing/hypot.c
new file mode 100644
index 0000000000..aad5259e92
--- /dev/null
+++ b/missing/hypot.c
@@ -0,0 +1,17 @@
+/* public domain rewrite of hypot */
+
+#include <math.h>
+
+double hypot(x,y)
+ double x, y;
+{
+ if (x < 0) x = -x;
+ if (y < 0) y = -y;
+ if (x < y) {
+ double tmp = x;
+ x = y; y = tmp;
+ }
+ if (y == 0.0) return x;
+ y /= x;
+ return x * sqrt(1.0+y*y);
+}
diff --git a/missing/strftime.c b/missing/strftime.c
index 6bce490249..3042649aeb 100644
--- a/missing/strftime.c
+++ b/missing/strftime.c
@@ -113,12 +113,6 @@ extern char *getenv();
extern char *strchr();
#endif
-#ifdef __GNUC__
-#define inline __inline__
-#else
-#define inline /**/
-#endif
-
#define range(low, item, hi) max(low, min(item, hi))
#if !defined(OS2) && !defined(MSDOS) && defined(HAVE_TZNAME)
diff --git a/missing/vsnprintf.c b/missing/vsnprintf.c
index d297209d06..489bf58361 100644
--- a/missing/vsnprintf.c
+++ b/missing/vsnprintf.c
@@ -108,9 +108,7 @@
#define __const
#endif /* People who don't like const sys_error */
-#if defined NT && !defined __MINGW32__
-typedef long size_t;
-#endif
+#include <stddef.h>
#ifndef NULL
#define NULL 0
@@ -1095,8 +1093,6 @@ vsnprintf(str, n, fmt, ap)
static char sccsid[] = "@(#)snprintf.c 8.1 (Berkeley) 6/4/93";
#endif /* LIBC_SCCS and not lint */
-#include <stddef.h>
-
#if defined(__STDC__)
# include <stdarg.h>
#else