summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-01-12 10:53:48 +0000
committerEric Andersen <andersen@codepoet.org>2001-01-12 10:53:48 +0000
commitddaf94095891a21cedd6a18d9178e4444fb937a7 (patch)
treeb47bcefa33533e4f41ecce4e3a1bee1d215e006e /libc
parent77879554671206102471bb282accb3251395d151 (diff)
Patch from James Graves <jgraves@deltamobile.com> to better handle m68k.
Also fixes 2 very important malloc bugs! Anyone using malloc (esp mmu-less) should update and recompile. -Erik
Diffstat (limited to 'libc')
-rw-r--r--libc/inet/resolv.c18
-rw-r--r--libc/misc/time/Makefile7
-rw-r--r--libc/stdlib/malloc-simple/alloc.c6
-rw-r--r--libc/stdlib/malloc/malloc.c15
-rw-r--r--libc/sysdeps/linux/m68k/README.m68k64
5 files changed, 94 insertions, 16 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 18f366e87..91442b3a9 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -56,10 +56,16 @@
#undef DEBUG
#ifdef DEBUG
-#define DPRINTF(X,args...) printf(X,args...)
+static inline void DPRINTF(const char *format, ...)
+{
+ va_list args;
+ va_start(args, format);
+ vfprintf(stderr, format, args);
+ va_end(args);
+}
#else
-#define DPRINTF(X,args...)
-#endif /* DEBUG */
+static inline void DPRINTF(const char *format, ...) { }
+#endif
#ifdef L_encodeh
int encode_header(struct resolv_header *h, unsigned char *dest, int maxlen)
@@ -481,7 +487,7 @@ int dns_lookup(const char *name, int type, int nscount, const char **nsip,
h.qdcount = 1;
h.rd = 1;
- DPRINTF("encoding header\n");
+ DPRINTF("encoding header\n", h.rd);
i = encode_header(&h, packet, PACKETSZ);
if (i < 0)
@@ -554,7 +560,7 @@ int dns_lookup(const char *name, int type, int nscount, const char **nsip,
/* unsolicited */
goto again;
- DPRINTF("Got response (i think)!\n");
+ DPRINTF("Got response %s\n", "(i think)!");
DPRINTF("qrcount=%d,ancount=%d,nscount=%d,arcount=%d\n",
h.qdcount, h.ancount, h.nscount, h.arcount);
DPRINTF("opcode=%d,aa=%d,tc=%d,rd=%d,ra=%d,rcode=%d\n",
@@ -778,7 +784,7 @@ int open_nameservers()
}
fclose(fp);
} else {
- DPRINTF("failed to open resolv.conf\n");
+ DPRINTF("failed to open %s\n", "resolv.conf");
}
DPRINTF("nameservers = %d\n", nameservers);
return 0;
diff --git a/libc/misc/time/Makefile b/libc/misc/time/Makefile
index d225614cb..4b9e98db9 100644
--- a/libc/misc/time/Makefile
+++ b/libc/misc/time/Makefile
@@ -26,12 +26,7 @@ LIBC=$(TOPDIR)libc.a
CSRC=localtime.c gmtime.c asctime.c ctime.c asc_conv.c tm_conv.c mktime.c \
localtime_r.c gmtime_r.c asctime_r.c ctime_r.c utimes.c adjtime.c \
- clock.c times.c difftime.c
-
-# strftime.c causes an internal compiler error with m68k-pic-coff-gcc.
-ifneq ($(TARGET_ARCH),m68k)
- CSRC += strftime.c
-endif
+ clock.c times.c difftime.c strftime.c
COBJS=$(patsubst %.c,%.o, $(CSRC))
OBJS=$(COBJS)
diff --git a/libc/stdlib/malloc-simple/alloc.c b/libc/stdlib/malloc-simple/alloc.c
index f31105d4e..f278a9583 100644
--- a/libc/stdlib/malloc-simple/alloc.c
+++ b/libc/stdlib/malloc-simple/alloc.c
@@ -99,10 +99,12 @@ void *realloc(void *ptr, size_t size)
if (size > 0) {
newptr = malloc(size);
- if (newptr && ptr)
+ if (newptr && ptr) {
memcpy(newptr, ptr, size);
+ free(ptr);
+ }
}
- if (ptr)
+ else
free(ptr);
return newptr;
}
diff --git a/libc/stdlib/malloc/malloc.c b/libc/stdlib/malloc/malloc.c
index b20c09390..fce529d80 100644
--- a/libc/stdlib/malloc/malloc.c
+++ b/libc/stdlib/malloc/malloc.c
@@ -495,7 +495,13 @@ static Block_t *bl_mapnew(size_t size)
map_size = PAGE_ALIGN(size);
pt = mmap(LARGE_MSTART, map_size, PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANON, 0, 0);
+#ifdef __HAS_NO_MMU__
+ MAP_SHARED | MAP_ANONYMOUS
+#else
+ MAP_PRIVATE | MAP_ANONYMOUS
+#endif
+ 0, 0);
+
if (pt == MAP_FAILED)
return (Block_t *) NULL;
@@ -517,7 +523,12 @@ void __bl_uncommit(Block_t * b)
#if M_DOTRIMMING
mmap(u_start, u_end - u_start, PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANON | MAP_FIXED, 0, 0);
+#ifdef __HAS_NO_MMU__
+ MAP_SHARED | MAP_ANONYMOUS |MAP_FIXED
+#else
+ MAP_PRIVATE | MAP_ANONYMOUS |MAP_FIXED
+#endif
+ 0, 0);
#endif
}
diff --git a/libc/sysdeps/linux/m68k/README.m68k b/libc/sysdeps/linux/m68k/README.m68k
new file mode 100644
index 000000000..697413852
--- /dev/null
+++ b/libc/sysdeps/linux/m68k/README.m68k
@@ -0,0 +1,64 @@
+
+README for uC-libc on the m68k[nommu] architecture
+
+James Graves <jgraves@deltamobile.com>
+
+For now (2001/1/9) support for the m68k should be considered "alpha"
+quality at best. It mostly works OK for some of the stuff I'm working
+on, but you can't fully compile other things (like the user
+applications for uClinux). Needs lots more testing.
+
+Only developed/tested with m68k-pic-coff-gcc 2.7.2.3-pic-060999, from
+Lineo.
+
+Configuration:
+
+ Read and edit the Config file, carefully.
+
+ TARGET_ARCH=m68k
+ CROSS = m68k-pic-coff-
+ CC = $(CROSS)gcc
+ STRIPTOOL = $(CROSS)strip
+ KERNEL_SOURCE=/opt/uClinux/linux
+ HAS_MMU = false
+ HAS_FLOATS = false
+ MALLOC = malloc-simple
+ INSTALL_DIR = /opt/uClinux/m68k-pic-coff
+
+ The regular malloc library is broken, dunno why. Use
+ simple-malloc.
+
+Installation:
+ Theoretically, you should be able to install right over the
+ existing uC-libc 0.9.1 files in
+ /opt/uClinux/m68k-pic-coff/include, but I recommend cleaning
+ out all the include files there.
+
+ The only file in there that's not from the old uC-libc is
+ assert.h, but I don't know why that would be the valid copy.
+
+ run:
+ make install
+
+Usage:
+ Any program you compile should have this added to CFLAGS:
+
+ -D__VFORK_MACRO__ -Dconst= -D__const=
+
+ (You need the equal sign so that const and __const are defined
+ as NULL instead of as '1') The 'const' keyword is broken for
+ m68k-pic-coff-gcc 2.7.2.3-pic-060999. There _was_ a fix
+ floating around, but apparently it didn't work.
+
+Problems:
+
+ I _may_ be able to help if you run into problems. Create a
+ really, really short program that demonstrates the problem,
+ and contact me.
+
+TODO:
+ Fix vfork().
+
+ Does crt0.o still need to be a separate file? Can't I just
+ stick it in libc.a and be done with it? Is that specified in
+ the GCC link options?