--- mit-pthreads/machdep/syscall-template-i386-freebsd-2.0.S.orig	Mon Sep 25 08:53:05 1995
+++ mit-pthreads/machdep/syscall-template-i386-freebsd-2.0.S	Sat Oct 10 17:22:21 1998
@@ -2,30 +2,41 @@
 
 #ifdef __STDC__
 
-#define	SYSCALL(x)					\
-	.globl _machdep_sys_##x##;		\
-									\
-_machdep_sys_##x:##;				\
-									\
-	movl $(SYS_##x##), %eax;		\
-	.byte 0x9a; .long 0; .word 7;	\
-	jb	1b;							\
-	ret;							
+#define SYS(X)		SYS_##X
+#ifdef __ELF__
+#define NAME(X)		machdep_sys_##X
+#else
+#define NAME(X)		_machdep_sys_##X
+#endif
 
 #else
 
-#define	SYSCALL(x)					\
-	.globl _machdep_sys_/**/x;		\
-									\
-_machdep_sys_/**/x:;				\
-									\
-	movl $(SYS_/**/x), %eax;		\
-	.byte 0x9a; .long 0; .word 7;	\
-	jb	1b;							\
-	ret;							
+#define SYS(X)		SYS_/**/X
+#ifdef __ELF__
+#define NAME(X)		machdep_sys_/**/X
+#else
+#define NAME(X)		_machdep_sys_/**/X
+#endif
 
 #endif
 
+#ifdef __ELF__
+#define END(X)		5: ; .type NAME(X),@function ; .size NAME(X),5b - NAME(X)
+#define KERNCALL	int $0x80
+#else
+#define END(X)
+#define KERNCALL	.byte 0x9a; .long 0; .word 7;
+#endif
+
+#define	SYSCALL(x)					\
+	.globl NAME(x);					\
+							\
+NAME(x):;						\
+	movl $(SYS(x)), %eax;				\
+	KERNCALL;					\
+	jb	1b;					\
+	ret;						\
+	END(x)
 
 /*
  * Initial asm stuff for all functions.
