I have the following Ada function
function Get_GPS_Epoch(Time : Standard_Types.Integer_Type)
return Global_Types.Long_GPS_Time_Type;
pragma import(C, get_GPS_Epoch, "getGpsEpoch");
On the C side
unsigned long long
getGpsEpoch(time_t startTime)
{
time_t gpsEpoch;
// Get current time
time_t curTime;
if (startTime == -1)
curTime = time(NULL);
else
curTime = startTime;
// Get gmtime broken down into parts
struct tm utcTime
if (curTime >=0 && gmtime_r(&curTime, &utcTime))
{
// Calculate the number of seconds from the Linux epoch
// to the GPS epoch which is midnight Jan 1st of the current year
gpsEpoch = curtime - (utcTime.tm_yday * 86400 +
utcTime.tm_hour * 3600 +
utcTime.tm_min * 60 +
utcTime.tm_sec);
}
// Convert to micro seconds
return (unsigned long long)gpsEpoch * 1000000;
}
My issue is on Ada I call the following
Get_GPS_Epoch(-1);
and then when it gets into the C function (using the debugger) the -1 becomes 4294967295.
(Both are 1111 1111 1111 1111 when the binary is printed by the debugger, making me think they are using different word sizes (QWORD vs DWORD) but I'm not experienced with issues like this.
This makes me think that time_t is an unsigned int but I'm not sure if it would act this way if it was. Would it just break? or am I just spoiled by Ada Range Check Exceptions?
In previous baselines, this worked. They were also on a different RHEL version.