-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
small changes to C, Pascal, Modula-2, em_opt, getopt(), Makefile #63
Conversation
These files come from old build systems, and are useless since the old build systems got deleted. TakeAction is from proto.make system and config.pm is from pmfile system.
Requested by @dram in davidgiven#41
These functions are in POSIX; hypot() is in C99. Also build cabs() because it rides with hypot(), but don't declare cabs() in any header file, because our compiler can't parse C99 "double complex" type. Touch build.lua so it sees that .c files moved.
This malloc.h might get confused with the private malloc.h in our libc. C programs should #include <stdlib.h> for malloc(). This tgmath.h has no useful content, and never worked because complex.h is missing. Touch build.lua (by deleting some whitespace) so the *.h globs see the deletions.
@hexcoder- reported in davidgiven#57 that our getpw() has bugs. I don't fix these bugs, because Illumos and Linux manual pages say that getpw() is obsolete. The function can overflow its buffer, so it is never safe to use. Our libc did not build getpw().
If feof(fp) or ferror(fp) was set, then our libc returned EOF for all later reads without trying to read. Our libc now behaves like BSD (and probably Illumos and musl) by checking only feof(fp). For difference, glibc doesn't check feof(fp). I described the difference between our libc and BSD libc in https://sourceforge.net/p/tack/mailman/message/35430300/
Fixes problem where `./program </dev/null` didn't show output.
Traditional C compilers had long but not unsigned long. I now assume that everyone can compile unsigned long. Remove macro UNSIGNED_ARITH and act like it is always defined. The type `unsigned arith` works because arith is a macro for long.
Reported by me in davidgiven#60 This doesn't change DIV. Right now a DIV b does floor division and a MOD b has the sign of b. This is the same as Lua, Python, Ruby, Tcl; but is different from other Modula-2 implementations.
If I edit optim.h to #define DIAGOPT then mktab must get rebuilt.
This is more useful when looking for patterns; lino - 1 is probably the line number in the patterns file. DIAGOPT is off by default but one can edit optim.h to enable it. The other changes just clean up whitespace.
Bug reported by Rune, see - https://sourceforge.net/p/tack/mailman/message/35809953/ - davidgiven#62 In EM code, beq and bne pop 2 values and compare them, but teq and tne pop only 1 value and compare it with zero. We need cms to compare 2 values; other patterns may convert cmi or cmu to cms.
Same reason as commit 649410b.
This prevents an overflow reported by @hexcoder- in davidgiven#56 lang/cem/cpp.ansi/LLlex.c used a plain 1 << ... and caused an overflow on machines where sizeof(int) < sizeof(long). Using 1L << ... would work for now but might fail later if arith became long long. C doesn't specify whether negative integers use 2's complement or some other format. Therefore, (arith) 1 << ... has an undefined value. It should still work because the value is some integer where the sign bit is set and all other bits are clear. (unsigned arith) 1 << ... would also get the sign bit, but casting it from unsigned back to signed would make the same undefined value. (arith) -1 << ... would assume 2's complement.
@dram reported a build failure in FreeBSD at davidgiven#1 (comment) Linux manual for getopt(3) says: > If the first character of optstring is '-', then each nonoption > argv-element is handled as if it were the argument of an option with > character code 1.... > > The use of '+' and '-' in optstring is a GNU extension. GNU/Linux and OpenBSD handle '-' in this special way, but FreeBSD seems not to. If '-' is not special, then em_ego can't find its input file, so the build must fail. This commit stops using '-' in both em_b and em_ego, but doesn't change mcg. Also fix em_ego -O3 to not act like -O4.
- Don't run BUILDSYSTEM more than once if there is more than one goal with '+'. - Don't pass goals without '+' to BUILDSYSTEM. - Use $(MAKE) because "make" might not be GNU make. For me, "make" is BSD make. - Add a comment so readers know MAKECMDGOALS is special. Over in README, remove Lua from requirements; we always ignore any installed Lua and build our own. Increase guesses for free space because we build more platforms. Don't need to type MAKEFLAGS=.
@@ -116,5 +116,6 @@ BEGIN | |||
(* dtrg: changed so that instead of opening /dev/tty, fd 0 is always used. *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment could use an update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a commit with the comment
(* kernigh: sent output to fd 1 *)
All LGTM --- thanks very much. Particularly for the ego fix; those rules are horrible. I'll wait for the Travis build and merge tomorrow, just to make sure it passes. (I think they're having problems with their OSX build farm.) |
I have gathered these small changes into one pull request.
If this is too much, I might remove some commits.