I've created a 68k cross gpc (from gpc20010623). I fairly quickly found that I needed RTS set functions such as_p_set_equal and haven't found them anywhere. Can anybody point me to them, or check over the stubs that I've come up with (which appear to work for sets with fewer than 32 members)? I'm paricularly unhappy with the p_set_equal which seems to get called with one pointer being NULL if one is testing against the empty set.
/* $Id$ */ #include <assert.h> /*------------------------------------------------------------------------ * *------------------------------------------------------------------------- */ typedef int SET_WORD; _p_set_equal(SET_WORD *s1, int s1z, int s1Size, SET_WORD *s2, int s2z, int s2Size) { if (s2 == (SET_WORD*)0) return *s1 == 0; if (s1 == (SET_WORD*)0) return *s2 == 0; return *s1 == *s2; } _p_set_copy(SET_WORD *s, int sz, int sSize, SET_WORD *d, int dz, int dSize) { assert(d && s); *d = *s; } _p_set_union(SET_WORD *s1, int s1z, int s1Size, SET_WORD *s2, int s2z, int s2Size, SET_WORD *d, int dz, int dSize) // [A] + [B] { *d = *s1 | *s2; } _p_set_intersection(SET_WORD *s1, int s1z, int s1Size, SET_WORD *s2, int s2z, int s2Size, SET_WORD *d, int dz, int dSize) // [A] * [B] { assert(d && s1 && s2); *d = *s1 & *s2; } _p_set_diff(SET_WORD *s1, int s1z, int s1Size, SET_WORD *s2, int s2z, int s2Size, SET_WORD *d, int dz, int dSize) // [s1] - [s2] { assert(d && s1 && s2); *d = *s1 & ~*s2; } _p_set_in(SET_WORD *s, int sz, int sSize, int bit) { return ((1<<bit) & *s) != 0; } __setbits(SET_WORD* out, unsigned long bitlength, long startbit, long endbit) { assert(startbit == endbit); *out = 1 << startbit; } /* $Log$ */
Loris Caren wrote:
I've created a 68k cross gpc (from gpc20010623). I fairly quickly found that I needed RTS set functions such as_p_set_equal and haven't found them anywhere. Can anybody point me to them, or check over the stubs that I've come up with (which appear to work for sets with fewer than 32 members)?
All the set routines are in the RTS (rts/sets.pas), just like many other required routines (files, mathematical, etc.). Unless you did something strange intentionally to prevent building of the RTS, you'd have to investigate what gets wrong while building GPC. The RTS should be compiled into libgpc.a and linked into every GPC compiled program. Of course, if (for some reason) you only compile with GPC (-c) and link with gcc or ld directly, you have to mention -lgpc (and -lm) explicitly.
Frank