[Gc] Re: GC + Windows Mobile + Threads + Patch for WINCE

Ivan Maidanski ivmai at mail.ru
Thu Aug 20 08:48:50 PDT 2009


Hi!

Zeyi Lee <biosli at hotmail.com> wrote:
> Dear Ivan:
>          I've downloaded the latest gc(ChangeLog date: 2009-08-11), and then merged your patch code for WinCE (Part 1/2/3).
>
>          I found there are several types of issues as following:
>          In diff144c
> -  } else {
> +  }
> +#endif
> I thought the added lines may could change like this:
> -  } else {
> +  } else
> +#endif
> ...

This is equivalent code since "else" is preceded by "return" - to my point of view "else #endif" construction is a bit ugly, so I've removed redundant "else" keyword here (and in another such place).

> When I finished the above-mentioned process, I started to compile the project. Then i got error as below:
> 1>Compiling...
> 1>misc.c
> 1>.\source\misc.c(871) : fatal error C1083: Cannot open include file: 'crtdbg.h': No such file or directory
> WinCE doesn't support "debug"function.
> Hence, I think i have to add a crtdbg.h for WinCE to libgc? Like this:http://www.codeproject.com/KB/mobile/ce_crtdbg.aspx?msg=1055787
> Meanwhile I changed misc.c provisional as following:
> --- C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/misc.c-revBASE.svn000.tmp.c        Aug 20 11:29:44 2009
> +++ D:/WorkBackup/My_Test_Project/libGCWinCE/libgc/source/misc.c    Aug 20 11:19:27 2009
> @@ -867,7 +867,7 @@
>
>
>  #if defined(MSWIN32) || defined(MSWINCE)
> -# if defined(_MSC_VER) && defined(_DEBUG)
> +# if defined(_MSC_VER) && defined(_DEBUG) && !defined(MSWINCE)
>  #  include <crtdbg.h>
>  # endif

Yes, I'll fix it in the same way.

>
> @@ -941,7 +941,15 @@
>        if (!tmp)
>           DebugBreak();
>  #     if defined(_MSC_VER) && defined(_DEBUG)
> -          _CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "%.*s", len, buf);
> +#              if defined(MSWINCE)
> +                  {
> +                          WCHAR temp[1024];
> +                          MultiByteToWideChar(CP_ACP, 0, buf, len, temp, 1024);
> +                          OutputDebugString(temp);
> +                  }
> +#              else
> +                          _CrtDbgReport(_CRT_WARN, NULL, 0, NULL, "%.*s", len, buf);
> +#              endif
>  #     endif
>        IF_NEED_TO_LOCK(LeaveCriticalSection(&GC_write_cs));
>        return tmp ? (int)written : -1;
>

Good point, thanks (in fact, I've never tried to compile GC with -D_DEBUG for WinCE) - I'll fix it (mostly as you suggest except for a trailing 0 should be added).

> The compiling went through but i was notified by a link error as shown below:
> 2>Linking...
> 2>libgc_smt2005_d.lib(os_dep.obj) : error LNK2019: unresolved external symbol backtrace referenced in function GC_save_callers
> 2>libgc_smt2005_d.lib(os_dep.obj) : error LNK2019: unresolved external symbol backtrace_symbols referenced in function GC_print_callers
>      So, I commented on the SAVE_CALL_CHAIN and SAVE_CALL_COUNT.

It seems there's no backtrace support in VC++ for WinCE. I'll check and fix it.

As a work-around, just use -DGC_HAVE_NO_BUILTIN_BACKTRACE for now.

>      It ran with run-time error:
>      Last error code: 87
> DuplicateHandle failed
> I found DuplicateHandle function help in MSDN for WINCE 5.0: http://msdn.microsoft.com/en-us/library/ms885208.aspx
> Below is its description by type.
> DuplicateHandle can duplicate handles only to the types of objects in the following table.
>  ...
>         I see NO functions in WinCE 5.0 can duplicate handles returned by CreateTread.
>          Could I change the code like this:
> +#ifdef UNDER_CE
> +       /* DuplicateHandle does not exist on WinCE */
> +       me -> handle = GetCurrentThread();
> +#else
> +       if (!DuplicateHandle(GetCurrentProcess(),
> +                GetCurrentThread(),
> +#endif

Yes, this sounds more correct for WinCE UNDER_CE.

> Could you pls help review it? Great thanks in advance!

Does it work for you with the above changes?

> Warmest regards,
> GC Beginner
> Zeyi Lee
>
> _________________________________________________________________
> уехЩмз  акт   ,п цюсж Т ЬощзЕак, Лю MClubсК цсяфКюжюже а  л цнйе
> http://club.msn.cn/?from=3
>

> PS: Why I got a mail from gc-bounces at napali.hpl.hp.com, as following:
>
> Your mail to 'Gc' with the subject
>
> Re: Patch for WinCE - part 3/3
>
> Is being held until the list moderator can review it for approval.

There's a size restriction for the ML posts - 40 KiB.

Bye.


More information about the Gc mailing list