Re: Misc portability cleanups

2002-03-31 Thread Russ Allbery

Brent Dax [EMAIL PROTECTED] writes:

 Ouch.  They actually expect you to be able to do anything useful without
 the other headers?

 It might actually be easier to just implement the headers ourselves on
 platforms that don't have them...

The provisions for free-standing implementations in the C standard are
primarily aimed at people using C as portable assembler for writing
embedded applications.  Viewed in that light, it makes sense that your
microwave may not have stdio.  :)  The idea is to define a subset of C
that can still be called C that doesn't include all of the extra stuff
that's unnecessary when all you're ever doing is reading and writing bytes
from special memory locations.

I think it's a real mistake for Microsoft to not provide a hosted
implementation for something like WinCE.  But that's just random
complaining; unfortunately, one can't solve portability routines by
expressing one's opinion that the decisions various platforms made were
stupid.  :)

-- 
Russ Allbery ([EMAIL PROTECTED]) http://www.eyrie.org/~eagle/



Re: Misc portability cleanups

2002-03-30 Thread Russ Allbery

Melvin Smith [EMAIL PROTECTED] writes:

 5- Other misc includes that should be wrapped in ifdefs are:
  sys/types.h, sys/stat.h, fcntl.h (btw parrot.h includes fcntl.h
  twice, once inside an ifdef and then by default).

What platform doesn't have sys/types.h?  It's one of the few headers that
I've *never* seen wrapped in ifdef even in code meant to compile on
extremely strange systems.

-- 
Russ Allbery ([EMAIL PROTECTED]) http://www.eyrie.org/~eagle/



Re: Misc portability cleanups

2002-03-30 Thread Josh Wilmes

You may be interested in the lib_deps target.

--Josh

At 0:49 on 03/31/2002 EST, Melvin Smith [EMAIL PROTECTED] wrote:

 I did some browsing of the code for potential problems in compiling
 for embedded platforms and/or general porting and here are some of the
 things I found.
 
 1- assert.h and use of assert()
  assert is easy enough to implement we need to do this and not depend
  on its existence on the target because its not guaranteed.
 2- errno.h same thing. Any use of errno is typically a system call, so it 
 should
  be wrapped in a platform generic way. On Win32 and WinCE we use
  GetLastError(), on UNIX and many others we can use errno.
 3- Use of stat and statbuf.  embed.c needs to be redone without it, period.
  We should go ahead and call the PIO routines instead, and add to PIO 
 as needed.
  We can implement a generic stat routine.
 4- Configure.pl needs to prompt for targetting another environment and
  have some specific hints file for each targettable environment.
  For WinCE stuff it might be worth querying ENV{} for stuff like CC, 
 TARGETCPU,
  PLATFORM, OSVERSION.
 5- Other misc includes that should be wrapped in ifdefs are:
  sys/types.h, sys/stat.h, fcntl.h (btw parrot.h includes fcntl.h twice, 
 once
  inside an ifdef and then by default).
 6- Need to check for definition of size_t and generate one if needed.
 
 Thats enough for now; baby steps. :)
 
 -Melvin
 





Re: Misc portability cleanups

2002-03-30 Thread Melvin Smith

At 09:56 PM 3/30/2002 -0800, Russ Allbery wrote:
Melvin Smith [EMAIL PROTECTED] writes:

  5- Other misc includes that should be wrapped in ifdefs are:
   sys/types.h, sys/stat.h, fcntl.h (btw parrot.h includes fcntl.h
   twice, once inside an ifdef and then by default).

What platform doesn't have sys/types.h?  It's one of the few headers that
I've *never* seen wrapped in ifdef even in code meant to compile on
extremely strange systems.

WinCE for one.

It has types.h but no sys/ stuff.

-Melvin




Re: Misc portability cleanups

2002-03-30 Thread Michael G Schwern

On Sun, Mar 31, 2002 at 12:49:08AM -0500, Melvin Smith wrote:
 I did some browsing of the code for potential problems in compiling
 for embedded platforms and/or general porting and here are some of the
 things I found.

Do embedded C compilers often not conform to ANSI C 89?


 1- assert.h and use of assert()
 assert is easy enough to implement we need to do this and not depend
 on its existence on the target because its not guaranteed.

assert is part of ANSI C 89, it should always be there.  The only
limitation is the expression must be an int.


 2- errno.h same thing.

errno is also in ANSI C 89.

However, using errno to transmit error messages has bitten us in the
ass in Perl5.


-- 

Michael G. Schwern   [EMAIL PROTECTED]http://www.pobox.com/~schwern/
Perl Quality Assurance  [EMAIL PROTECTED] Kwalitee Is Job One
Monkey tennis



Re: Misc portability cleanups

2002-03-30 Thread Melvin Smith

At 01:06 AM 3/31/2002 -0500, Michael G Schwern wrote:
On Sun, Mar 31, 2002 at 12:49:08AM -0500, Melvin Smith wrote:
  I did some browsing of the code for potential problems in compiling
  for embedded platforms and/or general porting and here are some of the
  things I found.

Do embedded C compilers often not conform to ANSI C 89?

Yes and no, depending on your definition.

ANSI C 89 specificies free-standing environments and hosted
environments. It does not require the former to provide any
more than these 4 - (float.h, limits.h, stdarg.h, stddef.h), besides
the language proper itself.

To qualify as a hosted environment they must provide the larger
list (stdio, stdlib, signal, string, assert, ctype, errno, locale, limits,
math, setjmp, stdarg, stddef, time).

WinCE on PocketPC is in my book a free-standing environment
by this definition. I've also coded on the Intel 8051 MC once upon a time
and I think I had some of the same issues, but its too fuzzy to
remember now.

CE is coming along though, 2.0 didn't provide stdio stuff, but 3.0 does
have some limited stuff.

  1- assert.h and use of assert()
  assert is easy enough to implement we need to do this and not depend
  on its existence on the target because its not guaranteed.

assert is part of ANSI C 89, it should always be there.  The only
limitation is the expression must be an int.


  2- errno.h same thing.

errno is also in ANSI C 89.

I'm not saying we shouldn't use it or include it, just not in the general
naked includes.

However, using errno to transmit error messages has bitten us in the
ass in Perl5.

Well for one, assert is so easy to implement its really kind of dumb that
the host compiler doesn't have it, but its also not worth fretting about, 
either.

However, anywhere we use assert() is probably a candidate for using
the Parrot exception routine anway.

-Melvin




RE: Misc portability cleanups

2002-03-30 Thread Brent Dax

Melvin Smith:
# At 01:06 AM 3/31/2002 -0500, Michael G Schwern wrote:
# On Sun, Mar 31, 2002 at 12:49:08AM -0500, Melvin Smith wrote:
#   I did some browsing of the code for potential problems in
# compiling
#   for embedded platforms and/or general porting and here
# are some of the
#   things I found.
# 
# Do embedded C compilers often not conform to ANSI C 89?
#
# Yes and no, depending on your definition.
#
# ANSI C 89 specificies free-standing environments and hosted
# environments. It does not require the former to provide any
# more than these 4 - (float.h, limits.h, stdarg.h, stddef.h), besides
# the language proper itself.
#
# To qualify as a hosted environment they must provide the larger
# list (stdio, stdlib, signal, string, assert, ctype, errno,
# locale, limits,
# math, setjmp, stdarg, stddef, time).
#
# WinCE on PocketPC is in my book a free-standing environment
# by this definition. I've also coded on the Intel 8051 MC once
# upon a time
# and I think I had some of the same issues, but its too fuzzy to
# remember now.
#
# CE is coming along though, 2.0 didn't provide stdio stuff,
# but 3.0 does
# have some limited stuff.

Ouch.  They actually expect you to be able to do anything useful without
the other headers?

It might actually be easier to just implement the headers ourselves on
platforms that don't have them...

#   1- assert.h and use of assert()
#   assert is easy enough to implement we need to do this
# and not depend
#   on its existence on the target because its not guaranteed.
# 
# assert is part of ANSI C 89, it should always be there.  The only
# limitation is the expression must be an int.
# 
# 
#   2- errno.h same thing.
# 
# errno is also in ANSI C 89.
#
# I'm not saying we shouldn't use it or include it, just not in
# the general
# naked includes.
#
# However, using errno to transmit error messages has bitten us in the
# ass in Perl5.
#
# Well for one, assert is so easy to implement its really kind
# of dumb that
# the host compiler doesn't have it, but its also not worth
# fretting about,
# either.
#
# However, anywhere we use assert() is probably a candidate for using
# the Parrot exception routine anway.

Or better, the incredibly under-utilized panic routine.

--Brent Dax [EMAIL PROTECTED]
@roles=map {Parrot $_} qw(embedding regexen Configure)

#define private public
--Spotted in a C++ program just before a #include




RE: Misc portability cleanups

2002-03-30 Thread Melvin Smith

At 10:56 PM 3/30/2002 -0800, Brent Dax wrote:
Melvin Smith:
# At 01:06 AM 3/31/2002 -0500, Michael G Schwern wrote:
# On Sun, Mar 31, 2002 at 12:49:08AM -0500, Melvin Smith wrote:
Ouch.  They actually expect you to be able to do anything useful without
the other headers?

Grin, I agree -- go ask Mr. Gates. :)

-Melvin