summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/minilibc.h
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2000-11-20 22:36:40 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2000-11-20 22:36:40 +0000
commit07e8572d9d5280867732fe881b9e7bd030988207 (patch)
tree4b987baf73cd14867c5f85ac06875fb8cb56c554 /mdk-stage1/minilibc.h
parent7ad3b65230799e074d065d1ac14835b7067aa7ec (diff)
downloaddrakx-backup-do-not-use-07e8572d9d5280867732fe881b9e7bd030988207.tar
drakx-backup-do-not-use-07e8572d9d5280867732fe881b9e7bd030988207.tar.gz
drakx-backup-do-not-use-07e8572d9d5280867732fe881b9e7bd030988207.tar.bz2
drakx-backup-do-not-use-07e8572d9d5280867732fe881b9e7bd030988207.tar.xz
drakx-backup-do-not-use-07e8572d9d5280867732fe881b9e7bd030988207.zip
first draft for init and minilibc
Diffstat (limited to 'mdk-stage1/minilibc.h')
-rw-r--r--mdk-stage1/minilibc.h142
1 files changed, 142 insertions, 0 deletions
diff --git a/mdk-stage1/minilibc.h b/mdk-stage1/minilibc.h
new file mode 100644
index 000000000..824ac5d6e
--- /dev/null
+++ b/mdk-stage1/minilibc.h
@@ -0,0 +1,142 @@
+/*
+ * Guillaume Cottenceau (gc@mandrakesoft.com)
+ *
+ * Copyright 2000 MandrakeSoft
+ *
+ * This software may be freely redistributed under the terms of the GNU
+ * public license.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+/*
+ * Portions from Erik Troan (ewt@redhat.com)
+ *
+ * Copyright 1996 Red Hat Software
+ *
+ */
+
+
+#include <stdarg.h>
+
+#define _LOOSE_KERNEL_NAMES 1
+
+#define NULL ((void *) 0)
+
+#define WIFSTOPPED(status) (((status) & 0xff) == 0x7f)
+#define WIFSIGNALED(status) (!WIFSTOPPED(status) && !WIFEXITED(status))
+#define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
+#define WTERMSIG(status) ((status) & 0x7f)
+#define WSTOPSIG(status) WEXITSTATUS(status)
+#define WIFEXITED(status) (WTERMSIG(status) == 0)
+
+#define MS_MGC_VAL 0xc0ed0000
+
+#define isspace(a) (a == ' ' || a == '\t')
+
+extern char ** _environ;
+
+extern int errno;
+
+/* Aieee, gcc 2.95+ creates a stub for posix_types.h on i386 which brings
+ glibc headers in and thus makes __FD_SET etc. not defined with 2.3+ kernels. */
+#define _FEATURES_H 1
+#include <linux/socket.h>
+#include <linux/types.h>
+#include <linux/time.h>
+#include <linux/if.h>
+#include <linux/un.h>
+#include <linux/loop.h>
+#include <linux/net.h>
+#include <asm/posix_types.h>
+#include <asm/termios.h>
+#include <asm/ioctls.h>
+#include <asm/unistd.h>
+#include <asm/fcntl.h>
+#include <asm/signal.h>
+
+
+#ifndef MINILIBC_INTERNAL
+static inline _syscall5(int,mount,const char *,spec,const char *,dir,const char *,type,unsigned long,rwflag,const void *,data);
+static inline _syscall5(int,_newselect,int,n,fd_set *,rd,fd_set *,wr,fd_set *,ex,struct timeval *,timeval);
+static inline _syscall4(int,wait4,pid_t,pid,int *,status,int,opts,void *,rusage)
+static inline _syscall3(int,write,int,fd,const char *,buf,unsigned long,count)
+static inline _syscall3(int,reboot,int,magic,int,magic_too,int,flag)
+static inline _syscall3(int,execve,const char *,fn,void *,argv,void *,envp)
+static inline _syscall3(int,read,int,fd,const char *,buf,unsigned long,count)
+static inline _syscall3(int,open,const char *,fn,int,flags,mode_t,mode)
+static inline _syscall3(int,ioctl,int,fd,int,request,void *,argp)
+static inline _syscall2(int,dup2,int,one,int,two)
+static inline _syscall2(int,kill,pid_t,pid,int,sig)
+static inline _syscall2(int,symlink,const char *,a,const char *,b)
+static inline _syscall2(int,chmod,const char * ,path,mode_t,mode)
+static inline _syscall2(int,sethostname,const char *,name,int,len)
+static inline _syscall2(int,setdomainname,const char *,name,int,len)
+static inline _syscall2(int,setpgid,int,name,int,len)
+static inline _syscall2(int,signal,int,num,void *,len)
+static inline _syscall1(int,umount,const char *,dir)
+static inline _syscall1(int,unlink,const char *,fn)
+static inline _syscall1(int,close,int,fd)
+static inline _syscall1(int,swapoff,const char *,fn)
+static inline _syscall0(int,getpid)
+static inline _syscall0(int,sync)
+#ifdef __sparc__
+/* Nonstandard fork calling convention :( */
+static inline int fork(void) {
+ int __res;
+ __asm__ __volatile__ (
+ "mov %0, %%g1\n\t"
+ "t 0x10\n\t"
+ "bcc 1f\n\t"
+ "dec %%o1\n\t"
+ "sethi %%hi(%2), %%g1\n\t"
+ "st %%o0, [%%g1 + %%lo(%2)]\n\t"
+ "b 2f\n\t"
+ "mov -1, %0\n\t"
+ "1:\n\t"
+ "and %%o0, %%o1, %0\n\t"
+ "2:\n\t"
+ : "=r" (__res)
+ : "0" (__NR_fork), "i" (&errno)
+ : "g1", "o0", "cc");
+ return __res;
+}
+#else
+static inline _syscall0(int,fork)
+#endif
+static inline _syscall0(pid_t,setsid)
+static inline _syscall3(int,syslog,int, type, char *, buf, int, len);
+#else
+static inline _syscall5(int,_newselect,int,n,fd_set *,rd,fd_set *,wr,fd_set *,ex,struct timeval *,timeval);
+static inline _syscall3(int,write,int,fd,const char *,buf,unsigned long,count)
+static inline _syscall2(int,socketcall,int,code,unsigned long *, args)
+#define __NR__do_exit __NR_exit
+extern inline _syscall1(int,_do_exit,int,exitcode)
+#endif
+
+#define select _newselect
+
+extern int errno;
+
+inline int socket(int a, int b, int c);
+inline int bind(int a, void * b, int c);
+inline int listen(int a, int b);
+inline int accept(int a, void * addr, void * addr2);
+
+void sleep(int secs);
+
+int strlen(const char * string);
+char * strcpy(char * dst, const char * src);
+void * memcpy(void * dst, const void * src, size_t count);
+int strcmp(const char * a, const char * b);
+int strncmp(const char * a, const char * b, int len);
+char * strchr(char * str, int ch);
+char * strncpy(char * dst, const char * src, int len);
+
+void print_str(char * string);
+void print_int(int i);
+/* Minimum printf which handles only characters, %d's and %s's */
+void printf(char * fmt, ...);