[GRASS5] Portability issues

Eric G. Miller egm2 at jps.net
Thu Oct 3 23:00:25 EDT 2002


On Thu, Oct 03, 2002 at 04:51:37PM +0100, Glynn Clements wrote:
[snip]
> Some of these could simply be replaced with ANSI functions, while
> others suggest that new functions should be added to e.g. libgis to
> improve portability.
> 
> Some comments on specific functions:
> 
> + open close creat read write lseek truncate
> 
> Many of these could probably be replaced with the ANSI stdio
> equivalents.

libgis uses file descriptors heavily, so POSIX functions are
useful/mandatory. ANSI doesn't have a truncate() or ftruncate().

> + mkdir chdir opendir closedir readdir
> 
> The ANSI libraries don't deal with directories. However, any system on
> which GRASS runs will have equivalent functionality; we just need to
> provide a portable interface.

Not a bad idea to have system interface (though Winders supposedly is
supporting POSIX these days...).

> + drand48 lrand48 srand48
> 
> These can be replaced with rand/srand. Presently, all programs which
> use (s.random, r.random, r.mapcalc) them can fall back to rand/srand,
> but [rs].random attempt to guess whether the *rand48 functions are
> available based upon platform macros rather than HAVE_DRAND48.

Might be good to include a couple random number generators in libgis.
Sources for a number of good ones are freely available..
 
> + snprintf
> 
> C9X defines this, so in a couple of decades it won't be a problem. For
> now, a wide variety of solutions are possible, all with their own
> advantages and disadvantages.

Couple of *decades*! ;^) I think mostly we'd rather have an asprintf()
available...

> + sigaction sigemptyset
> 
> Only used by r.mapcalc. signal() can be used instead, although
> signal() has problems of its own (BSD-vs-SysV signal semantics,
> general lack of flexibility).

sigaction is POSIX, so should be fairly portable by now.  ANSI only
minimally describes signals, hence the BSD vs. SysV, etc...

[snip]

> + putenv
> 
> Used by XDRIVER; it probably doesn't need to be portable.

Why not setenv()?

[snip]
> + gethostname
> 
> Used by G__machine_name(), which is sensible enough. Presumably
> equivalent functionality is available on any networked system (and, on
> non-networked systems, you don't really need a per-machine
> identifier).

That's mostly for the tmpfile thing these days, no?  Probably could
think about getting rid of it if the whole mapset permissions thing
is redone.. (Hmm, there's also that email interface...).

-- 
begin 664 .signature
M<F5L;&E-("Y'(&-I<D4@/G1E;BYS<&I`,FUG93P)"`@("`@("`@("`@("`@(
M"`@("`@("`@("`@("`@("`A%<FEC($<N($UI;&QE<B`\96=M,D!J<',N;F5T
"/@H`
`
end




More information about the grass-dev mailing list