[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] MiNTlib timing related functions behavior/performance



Hi,

On torstai 18 huhtikuu 2013, Helmut Karlowski wrote:
> In case you're using bash: It has cat built-in, which can fail with the
> cat - -thing.
[...]

I use Bash, but for some reason all of these work, at least now.


> You can mkdir the multibyte-directory and cvs co or up (don't remember)
>  from there. Make sure to remove the .P-files for the
> multibyte-functions.

Then make fails because multibyte directory doesn't have
a Makefile with "all" or "clean" targets...

If I remove "multibyte" targets from top Makefile, make fails
to multibyte/SRCFILES missing, needed by lib/Makefile.

After commenting out all references to:
- mbytedir
- MBYTESRCS
- MBYTEOBJS
- $(mbytedir)/SRCFILES

from "buildrules" file, MiNTlib finally starts to build.


Then it fails on wctrans.c, to a parse error on wchar.h.

This is due to nice circular inclusion mess:
- wctrans.c includes wctype.h
- wctype.h include wchar.h, for wchar_t definition
- wchar.h includes wctype.h, for wctype_t definition,
  but due to recursive include protection, it doesn't get that.
  -> parse error when wctype_t is needed

The last one is stupid because wctype_t is needed for
declarations that are already declared in wctype.h!

Removing those duplicate declarations from wchar.h, lets
the build proceed.


Next it broke on unrecognized "-fwrapv" GCC option.
Commenting them out from buildrules lets the build
continue...


Finally I was able to build nanosleep.c and fix the patch.
New patch is attached.


After that the build failed to gmp/ldbl2mpn.c math.h
inclusion which didn't find math-68881.h.

After prefixing the include file name with missing "bits/",
build continued and finally finished.


Attached is the patch of stuff I had to do to get MiNTlib to
build, as a reminder.  Somebody should fix those things
properly. :-/


	- Eero
--- posix/nanosleep.c	13 Dec 2010 09:35:35 -0000	1.1
+++ posix/nanosleep.c	18 Apr 2013 20:51:11 -0000
@@ -5,6 +5,13 @@
 #include <time.h>
 #include <sys/time.h>
 #include <errno.h>
+#include <time.h>
+
+#include "lib.h"	/* __mint */
+
+#define TIMESPEC_TO_USEC(ts) ((ts)->tv_sec * 1000000L + (ts)->tv_nsec / 1000)
+#define USEC_PER_TICK (1000000L / ((unsigned long)CLOCKS_PER_SEC))
+#define	USEC_TO_CLOCK_TICKS(us)	((us) / USEC_PER_TICK )
 
 enum { BILLION = 1000 * 1000 * 1000 };
 
@@ -20,6 +27,19 @@
 		return -1;
 	}
 
+	if (!__mint) {
+		/* on TOS this cannot be interrupted and
+		 * there's no Tgettimeofday/Fselect,
+		 * so just busyloop
+		 */
+		long stop;
+		__useconds_t useconds = TIMESPEC_TO_USEC(req);
+		stop = _clock() + USEC_TO_CLOCK_TICKS(useconds);
+		while (_clock() < stop)
+			;
+		return 0;
+	}
+
 	wait.tv_sec = req->tv_sec;
 	wait.tv_usec = (req->tv_nsec + 999) / 1000;
 	if (wait.tv_usec == 1000000) {
--- include/math.h	20 Mar 2011 08:27:03 -0000	1.7
+++ include/math.h	18 Apr 2013 20:51:11 -0000
@@ -138,7 +138,7 @@
 #endif
 
 #if _INLINE_MATH
-# include <math-68881.h>
+# include <bits/math-68881.h>
 #endif
 
 #define HUGE HUGE_VAL
--- include/wchar.h	16 Apr 2013 20:10:00 -0000	1.4
+++ include/wchar.h	18 Apr 2013 20:51:11 -0000
@@ -158,6 +158,7 @@
 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE)
 int wcwidth (wchar_t);
 int wcswidth (const wchar_t *, size_t);
+/* These are already declared by wctype.h, included above:
 int       iswalnum(wint_t);
 int       iswalpha(wint_t);
 int       iswblank(wint_t);
@@ -176,6 +177,7 @@
 wctype_t  wctype(const char *);
 #undef iswdigit
 #define iswdigit(a) ((unsigned)(a)-'0' < 10)
+*/
 #endif
 
 #ifdef __cplusplus
--- Makefile	7 Mar 2013 18:56:24 -0000	1.16
+++ Makefile	18 Apr 2013 20:51:11 -0000
@@ -23,13 +23,15 @@
 endif
 
 SUBDIRS = include syscall startup argp conf crypt dirent gmp login mintlib \
-  misc multibyte posix pwdgrp shadow signal socket stdiio stdio stdlib \
+  misc posix pwdgrp shadow signal socket stdiio stdio stdlib \
   string sysvipc termios time unix lib tz sunrpc
+#multibyte
 DIST_SUBDIRS = argp conf crypt dirent gmp include lib \
-  login mintlib misc multibyte posix pwdgrp shadow signal socket startup \
+  login mintlib misc posix pwdgrp shadow signal socket startup \
   stdiio stdio stdlib string sunrpc syscall sysvipc termios time tz unix
 TEST_SUBDIRS = argp crypt dirent login mintlib misc posix pwdgrp shadow signal \
   socket startup stdiio stdio stdlib string time tz unix
+#multibyte
 
 ifeq ($(WITH_PROFILE_LIB), yes)
   SUBDIRS += lib_p
--- buildrules	7 Mar 2013 18:56:24 -0000	1.25
+++ buildrules	18 Apr 2013 20:51:11 -0000
@@ -54,7 +54,7 @@
 logindir   := $(top_srcdir)/login
 mintlibdir := $(top_srcdir)/mintlib
 miscdir    := $(top_srcdir)/misc
-mbytedir   := $(top_srcdir)/multibyte
+#mbytedir   := $(top_srcdir)/multibyte
 posixdir   := $(top_srcdir)/posix
 pwdgrpdir  := $(top_srcdir)/pwdgrp
 shadowdir  := $(top_srcdir)/shadow
@@ -83,7 +83,7 @@
 LOGINSRCS   := $(addprefix $(logindir)/,   $(LOGINCFILES))
 MINTLIBSRCS := $(addprefix $(mintlibdir)/, $(MINTLIBCFILES))
 MISCSRCS    := $(addprefix $(miscdir)/,    $(MISCCFILES))
-MBYTESRCS   := $(addprefix $(mbytedir)/,   $(MBYTECFILES))
+#MBYTESRCS   := $(addprefix $(mbytedir)/,   $(MBYTECFILES))
 POSIXSRCS   := $(addprefix $(posixdir)/,   $(POSIXCFILES))
 PWDGRPSRCS  := $(addprefix $(pwdgrpdir)/,  $(PWDGRPCFILES))
 RPCSVCSRCS  := $(addprefix $(sunrpcdir)/,  $(RPCSVCCFILES))
@@ -102,10 +102,11 @@
 TZSRCS      := $(addprefix $(tzdir)/,      $(TZCFILES))
 UNIXSRCS    := $(addprefix $(unixdir)/,    $(UNIXCFILES))
 SRCS := $(ARGPSRCS) $(CRYPTSRCS) $(DIRENTSRCS) $(GMPSRCS) $(LOGINSRCS) $(MINTLIBSRCS) \
-  $(MISCSRCS) $(MBYTESRCS) $(POSIXSRCS) $(PWDGRPSRCS) $(RPCSVCSRCS) $(SHADOWSRCS) \
+  $(MISCSRCS) $(POSIXSRCS) $(PWDGRPSRCS) $(RPCSVCSRCS) $(SHADOWSRCS) \
   $(SIGNALSRCS) $(SOCKETSRCS) $(STDIOSRCS) $(STDIOSRCS) $(STDLIBSRCS) \
   $(STRINGSRCS) $(SUNRPCSRCS) $(SYSCALLSRCS) $(SYSVIPCSRCS) $(TERMIOSSRCS) \
   $(TIMESRCS) $(TZSRCS) $(UNIXSRCS)
+# $(MBYTESRCS)
 
 ifeq ($(libsize), _p)
 CFLAGS-_mon.S = -DPROFILING
@@ -117,11 +118,11 @@
 NOCFLAGS-profil-posix.c = -pg -fomit-frame-pointer
 #NOCFLAGS-linea.c = -pg -fomit-frame-pointer -O2 -O
 #DEFS-vfscanf.c = -DNO_BUG_IN_ISO_C_CORRIGENDUM_1
-CFLAGS-localtime.c = -DUSG_COMPAT -DALL_STATE -DPCTS -DSTD_INSPIRED -DNOID -fwrapv
+CFLAGS-localtime.c = -DUSG_COMPAT -DALL_STATE -DPCTS -DSTD_INSPIRED -DNOID #-fwrapv
 CFLAGS-asctime.c = -DNOID
 CFLAGS-strftime.c = -DNOID
 CFLAGS-difftime.c = -DNOID
-CFLAGS-nanosleep.c = -fwrapv
+CFLAGS-nanosleep.c = #-fwrapv
 CFLAGS-vfprintf.c = -Wno-uninitialized
 CFLAGS-ivfprintf.c = -Wno-uninitialized
 DEFS-ident.c = -DVERSION=\"$(VERSION)\"
@@ -149,7 +150,7 @@
 LOGINOBJS   := $(addsuffix .o, $(basename $(notdir $(LOGINSRCS))))
 MINTLIBOBJS := $(addsuffix .o, $(basename $(notdir $(MINTLIBSRCS))))
 MISCOBJS    := $(addsuffix .o, $(basename $(notdir $(MISCSRCS))))
-MBYTEOBJS   := $(addsuffix .o, $(basename $(notdir $(MBYTESRCS))))
+#MBYTEOBJS   := $(addsuffix .o, $(basename $(notdir $(MBYTESRCS))))
 POSIXOBJS   := $(addsuffix .o, $(basename $(notdir $(POSIXSRCS))))
 PWDGRPOBJS  := $(addsuffix .o, $(basename $(notdir $(PWDGRPSRCS))))
 RPCSVCOBJS  := $(addsuffix .o, $(basename $(notdir $(RPCSVCSRCS))))
@@ -168,14 +169,16 @@
 TZOBJS      := $(addsuffix .o, $(basename $(notdir $(TZSRCS))))
 UNIXOBJS    := $(addsuffix .o, $(basename $(notdir $(UNIXSRCS))))
 OBJS := $(ARGPOBJS) $(CRYPTOBJS) $(DIRENTOBJS) $(GMPOBJS) $(LOGINOBJS) $(MINTLIBOBJS) \
-  $(MISCOBJS) $(MBYTEOBJS) $(POSIXOBJS) $(PWDGRPOBJS) $(RPCSVCOBJS) $(SHADOWOBJS) \
+  $(MISCOBJS) $(POSIXOBJS) $(PWDGRPOBJS) $(RPCSVCOBJS) $(SHADOWOBJS) \
   $(SIGNALOBJS) $(SOCKETOBJS) $(STDIIOOBJS) $(STDIOOBJS) $(STDLIBOBJS) \
   $(STRINGOBJS) $(SUNRPCOBJS) $(SYSCALLOBJS) $(SYSVIPCOBJS) $(TERMIOSOBJS) \
   $(TIMEOBJS) $(TZOBJS) $(UNIXOBJS)
+# $(MBYTEOBJS)
 LIBCOBJS := $(ARGPOBJS) $(CRYPTOBJS) $(DIRENTOBJS) $(GMPOBJS) $(LOGINOBJS) $(MINTLIBOBJS) \
-  $(MISCOBJS) $(MBYTEOBJS) $(POSIXOBJS) $(PWDGRPOBJS) $(SHADOWOBJS) $(SIGNALOBJS) \
+  $(MISCOBJS) $(POSIXOBJS) $(PWDGRPOBJS) $(SHADOWOBJS) $(SIGNALOBJS) \
   $(STDIOOBJS) $(STDLIBOBJS) $(STRINGOBJS) $(SYSCALLOBJS) $(SYSVIPCOBJS) \
   $(TERMIOSOBJS) $(TIMEOBJS) $(TZOBJS) $(UNIXOBJS) $(SUNRPCOBJS) $(SOCKETOBJS)
+# $(MBYTEOBJS)
 
 # All modules that reference vfprintf or vfscanf should be listed here.
 LIBIIO_ADDOBJS = err.o error.o doprnt.o dprintf.o fscanf.o scanf.o vscanf.o \
@@ -217,9 +220,11 @@
 
 ifndef top_distdir    # Not needed when making distributions.
 
+# $(mbytedir)/SRCFILES
+
 # Copy SRCFILES from source directory here.
 $(top_srcdir)/CFILES: $(argpdir)/SRCFILES $(cryptdir)/SRCFILES $(direntdir)/SRCFILES \
-  $(gmpdir)/SRCFILES $(mbytedir)/SRCFILES $(logindir)/SRCFILES $(mintlibdir)/SRCFILES \
+  $(gmpdir)/SRCFILES $(logindir)/SRCFILES $(mintlibdir)/SRCFILES \
   $(miscdir)/SRCFILES $($(posixdir)/SRCFILES $(pwdgrpdir)/SRCFILES \
   $(shadowdir)/SRCFILES $(signaldir)/SRCFILES $(socketdir)/SRCFILES \
   $(stdiiodir)/SRCFILES $(stdiodir)/SRCFILES $(stdlibdir)/SRCFILES \
@@ -235,7 +240,7 @@
 	sed -e 's,^SRCFILES *=,LOGINCFILES =,g' $(logindir)/SRCFILES >>$@
 	sed -e 's,^SRCFILES *=,MINTLIBCFILES =,g' $(mintlibdir)/SRCFILES >>$@
 	sed -e 's,^SRCFILES *=,MISCCFILES =,g' $(miscdir)/SRCFILES >>$@
-	sed -e 's,^SRCFILES *=,MBYTECFILES =,g' $(mbytedir)/SRCFILES >>$@
+	#sed -e 's,^SRCFILES *=,MBYTECFILES =,g' $(mbytedir)/SRCFILES >>$@
 	sed -e 's,^SRCFILES *=,POSIXCFILES =,g' $(posixdir)/SRCFILES >>$@
 	sed -e 's,^SRCFILES *=,PWDGRPCFILES =,g' $(pwdgrpdir)/SRCFILES >>$@
 	sed -e 's,^SRCFILES *=,SHADOWCFILES =,g' $(shadowdir)/SRCFILES >>$@