@@ -26,65 +26,13 @@ guint utility_ipPortHash(in_addr_t ip, in_port_t port) {
2626 return hash_value ;
2727}
2828
29- guint utility_int16Hash (gconstpointer value ) {
30- utility_debugAssert (value );
31- /* make sure upper bits are zero */
32- gint key = 0 ;
33- key = (gint ) * ((gint16 * )value );
34- return g_int_hash (& key );
35- }
36-
37- gboolean utility_int16Equal (gconstpointer value1 , gconstpointer value2 ) {
38- utility_debugAssert (value1 && value2 );
39- /* make sure upper bits are zero */
40- gint key1 = 0 , key2 = 0 ;
41- key1 = (gint ) * ((gint16 * )value1 );
42- key2 = (gint ) * ((gint16 * )value2 );
43- return g_int_equal (& key1 , & key2 );
44- }
45-
46- gint utility_doubleCompare (const gdouble * value1 , const gdouble * value2 , gpointer userData ) {
47- utility_debugAssert (value1 && value2 );
48- /* return neg if first before second, pos if second before first, 0 if equal */
49- return (* value1 ) == (* value2 ) ? 0 : (* value1 ) < (* value2 ) ? -1 : +1 ;
50- }
51-
5229gint utility_simulationTimeCompare (const CSimulationTime * value1 , const CSimulationTime * value2 ,
5330 gpointer userData ) {
5431 utility_debugAssert (value1 && value2 );
5532 /* return neg if first before second, pos if second before first, 0 if equal */
5633 return (* value1 ) == (* value2 ) ? 0 : (* value1 ) < (* value2 ) ? -1 : +1 ;
5734}
5835
59- gchar * utility_getHomePath (const gchar * path ) {
60- GString * sbuffer = g_string_new ("" );
61- if (g_ascii_strncasecmp (path , "~" , 1 ) == 0 ) {
62- /* replace ~ with home directory */
63- const gchar * home = g_get_home_dir ();
64- g_string_append_printf (sbuffer , "%s%s" , home , path + 1 );
65- } else {
66- g_string_append_printf (sbuffer , "%s" , path );
67- }
68- return g_string_free (sbuffer , FALSE);
69- }
70-
71- guint utility_getRawCPUFrequency (const gchar * freqFilename ) {
72- /* get the raw speed of the experiment machine */
73- guint rawFrequencyKHz = 0 ;
74- gchar * contents = NULL ;
75- gsize length = 0 ;
76- GError * error = NULL ;
77- if (freqFilename && g_file_get_contents (freqFilename , & contents , & length , & error )) {
78- utility_debugAssert (contents );
79- rawFrequencyKHz = (guint )atoi (contents );
80- g_free (contents );
81- }
82- if (error ) {
83- g_error_free (error );
84- }
85- return rawFrequencyKHz ;
86- }
87-
8836static GString * _utility_formatError (const gchar * file , gint line , const gchar * function ,
8937 const gchar * message , va_list vargs ) {
9038 GString * errorString = g_string_new ("**ERROR ENCOUNTERED**\n" );
@@ -147,13 +95,6 @@ gchar* utility_strvToNewStr(gchar** strv) {
14795 return g_string_free (strBuffer , FALSE);
14896}
14997
150- struct timespec utility_timespecFromMillis (int64_t millis ) {
151- return (struct timespec ){
152- .tv_sec = millis / 1000 , // ms to sec
153- .tv_nsec = (millis % 1000 ) * 1000000 , // ms to ns
154- };
155- }
156-
15798int return_code_for_signal (int signal ) {
15899 // To calculate the return code if the process exited by a signal,
159100 // follow the behaviour of bash and add 128 to to the signal.
0 commit comments