Skip to content

Commit 8733183

Browse files
committed
Removed unused C util code
1 parent bb40709 commit 8733183

2 files changed

Lines changed: 0 additions & 68 deletions

File tree

src/main/utility/utility.c

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
5229
gint 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-
8836
static 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-
15798
int 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.

src/main/utility/utility.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,8 @@
9090
#endif
9191

9292
guint utility_ipPortHash(in_addr_t ip, in_port_t port);
93-
guint utility_int16Hash(gconstpointer value);
94-
gboolean utility_int16Equal(gconstpointer value1, gconstpointer value2);
95-
gint utility_doubleCompare(const gdouble* value1, const gdouble* value2, gpointer userData);
9693
gint utility_simulationTimeCompare(const CSimulationTime* value1, const CSimulationTime* value2,
9794
gpointer userData);
98-
gchar* utility_getHomePath(const gchar* path);
99-
guint utility_getRawCPUFrequency(const gchar* freqFilename);
10095
gboolean utility_isRandomPath(const gchar* path);
10196

10297
gchar* utility_strvToNewStr(gchar** strv);
@@ -105,10 +100,6 @@ __attribute__((__format__(__printf__, 4, 5)))
105100
_Noreturn void utility_handleError(const gchar* file, gint line, const gchar* funtcion,
106101
const gchar* message, ...);
107102

108-
/* Converts millis milliseconds to a timespec with the corresponding number
109-
* of seconds and nanoseconds. */
110-
struct timespec utility_timespecFromMillis(int64_t millis);
111-
112103
/* If a process exited by a signal, use this return code. */
113104
int return_code_for_signal(int signal);
114105

0 commit comments

Comments
 (0)