Subject | Re: UDF - Windows vs Linux |
---|---|
Author | taliyev |
Post date | 2006-05-25T18:36:06Z |
Thank you for your help.
BY VALUE trick fixed the first function, but what about the second
one?
--- In firebird-support@yahoogroups.com, "Ivan Prenosil"
<Ivan.Prenosil@...> wrote:
BY VALUE trick fixed the first function, but what about the second
one?
--- In firebird-support@yahoogroups.com, "Ivan Prenosil"
<Ivan.Prenosil@...> wrote:
>& Windows*/
> > DECLARE EXTERNAL FUNCTION MOY
> > RETURNS SMALLINT
>
> I guess there should be
> RETURNS SMALLINT BY VALUE
>
>
> > /* tbuf below is declared oudside and works for other udfs Linux
> > tbuf = localtime(&time_sec);C
>
> Does not look much threadsafe.
>
>
> Why don't you just use standard functions instead of UDFs ?
> e.g. EXTRACT(MONTH FROM CURRENT_DATE)
>
> Ivan
>
>
> ----- Original Message -----
> From: "taliyev" <taliyev@...>
> To: <firebird-support@yahoogroups.com>
> Sent: Thursday, May 25, 2006 5:18 PM
> Subject: [firebird-support] UDF - Windows vs Linux
>
>
> I have to port FB udf library from Windows to Linux. I have moved
> code of our udfs to our Linux box and it has compiled and linkedI
> into library without any troubles. Here is where problem started.
> have to mention here that all functions work well on our Windows
> server. Most of the functions work on Linux as well, but some of
> them cause FB to abandon all connections and restart. Here are two
> samples:
>
> Declaration:
>
> DECLARE EXTERNAL FUNCTION MOY
> RETURNS SMALLINT
> ENTRY_POINT 'fn_moy' MODULE_NAME 'CODASlib';
>
> C code:
>
> short EXPORT fn_moy()
> {
> long time_sec;
> short r_short;
> time (&time_sec);
> /* tbuf below is declared oudside and works for other udfs Linux &
> Windows*/
> tbuf = localtime(&time_sec);
> r_short = (short) (tbuf->tm_mon + 1);
> return r_short;
> }
>
> Here is another one.
>
> Declaration:
>
> DECLARE EXTERNAL FUNCTION MAKEWEEKNUMID
> INTEGER
> RETURNS INTEGER BY VALUE
> ENTRY_POINT 'fn_MakeWeekNumID' MODULE_NAME 'CODASlib';
>
> C code:
>
> int EXPORT fn_MakeWeekNumID(ARG(int*, yyyymmdd))
> ARGLIST(int *yyyymmdd)
> {
> long bDate = (long) julian_date(2, 1, 2000);
> int yyyy = *yyyymmdd / 10000;
> int mm = (*yyyymmdd / 100) % 100;
> int dd = *yyyymmdd % 100;
> long ThisDate = (long) julian_date(dd, mm, yyyy);
> if (ThisDate < bDate)
> return (0);
> return (int) ((ThisDate - bDate)/7 +1);
> }
>
> Once again this declaration and code work on Windows, but break FB
> on Linux. What is wrong here? Where is my problem?
>
> Thanks
>