Re: [gnome-db] gda-parameter-list.c:300: uint + mmap

On 1/19/07, Brecht Sanders <brecht sanders org> wrote:
> > I am trying to compile libgda-2.99.2 for win32 using the mingw/msys
> > compiler environment.
> > I got pretty far into the compilation, but one of the pitfalls was this:
> >
> > The file libgda/gda-parameter-list.c has the following on lines 300 and
> > 304:
> >    gda_value_set_ushort (value, va_arg (ap, uint));
> >    g_value_set_uchar (value, va_arg (ap, uint));
> > I was able to get by this problem with a simple "-Duint=guint"
> > Apparently the uint type does not exist on my platform, but guint doe
> > and glib defines it simply as unsigned int.
> It should normally be unsigned short (I'll correct this), does it
> exist on Windows?



> > The show stopper I am facing though is in libgda/gda-data-model-import.c
> > which uses sys/mman.h for memory mapped file access.
> > The win32 platform does not have this include file.
> > Is there any chance this code could be changed to be win32 compatible?
> Windows does have mapped files, but the code is different, AFAIK it
> uses OpenFileMapping function call. Modifications to the code should
> not be very difficult (modifications should be included in #ifdef
> LIBGDA_WIN32 sections).
> However because I know nothing of Win32 programming and I don't have a
> win32 box at hand, I won't code it myself (you'll find some examples
> fo such code for instance in

In that case I'll be glad to make my contribution. Below is the patch I have
Note that I have moved munmap after close. Doesn't that seem more logical?

Yes, right.

I haven't tested it yet though.
Can you tell me what the easiest way is to test it?

As there is not (yet) regression tests in libgda, you'll have to write
your own code, or if you have libgnomedb compiled, then you can run
"test-dyn-widgets -t 14" in the testing/ directory and try to load a
CVS file for example.

However I think I need to be able to build the entire library before I can
test anything...

That'd be better...

My next problem is strtok_r which doesn't exist on win32.
I believe strtok is thread safe.

the strtok_r() is nt about thread safeness, but it avoids to use a
static buffer (which can lead to problems if several strings are to be
splitted at the same time).

If it is I guess adding some code like this woudl fix it:
    #ifdef _WIN32
      #define strtok_r(s,d,p) strtok(s,d)
What would be the best place to add this? I was thinking libgda/gda-decl.h?

This should work, but code analysis is required here to make sure that
there are never 2 strings being splitted at the same time (putting
this define in libgda/gda-decl.h seems ok for me).

Could you send me tha patch you made as an attachment instead, to keep
the formatting correct (avoid long lines truncation, etc)?

Thanks a lot,


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