Port to GLib >= 2.32 GThread API

- Use g_thread_new instead of g_thread create
- Drop explicit call of g_thread_init, it is done implicitely by GLib
  since 2.32
- Since this bumps the minimum required GLib version add and extend the
  pkg-config based version checks to error out on older GLib versions
This commit is contained in:
Stefan Gehn 2013-12-17 21:23:04 +01:00
parent 766bcc70f5
commit 6e3ee7db10
12 changed files with 21 additions and 19 deletions

View File

@ -25,6 +25,8 @@ GKrellM Changelog
nfs-timeout polling interval
* Patch from Alexandre Rostovtsev: Explicitely link against gmodule-2.0
* Add support for GPU-Z sensor information on Windows
* Increase minimum required GLib version to 2.32, some parts of gkrellm
use newer GLib API
2.3.5 - Thu Oct 7, 2010
------------------------

View File

@ -113,11 +113,11 @@ OBJS = main.o monitor.o mail.o plugins.o glib.o utils.o sysdeps-unix.o log.o
all: gkrellmd$(BINEXT)
gkrellmd$(BINEXT): $(OBJS) $(EXTRAOBJS)
gkrellmd$(BINEXT): check_env $(OBJS) $(EXTRAOBJS)
$(CC) $(OBJS) $(EXTRAOBJS) -o $@ \
$(LDFLAGS) $(LIBS) $(LINK_FLAGS)
static: $(OBJS) $(EXTRAOBJS)
static: check_env $(OBJS) $(EXTRAOBJS)
$(CC) $(OBJS) $(EXTRAOBJS) -o gkrellmd.static -static \
$(LDFLAGS) $(LIBS) $(LINK_FLAGS)
@ -252,5 +252,9 @@ win32-libgkrellmd.o: win32-libgkrellmd.c win32-plugin.h $(GKRELLMD_H)
libgkrellmd.a: win32-libgkrellmd.o
ar -cr libgkrellmd.a win32-libgkrellmd.o
# Checks if the build environment is ok
check_env:
$(PKG_CONFIG) --atleast-version=2.32 glib-2.0
%.o: %.c
$(CC) -c -Wall $(FLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@

View File

@ -1198,10 +1198,6 @@ gkrellmd_run(gint argc, gchar **argv)
gkrellm_sys_main_init();
drop_privileges();
#if GLIB_CHECK_VERSION(2,0,0)
g_thread_init(NULL);
#endif
_GK.start_time = time(0);
if (_GK.update_HZ < 1 || _GK.update_HZ > 10)
_GK.update_HZ = 3;

View File

@ -1522,7 +1522,7 @@ update_fs(GkrellmdMonitor *mon, gboolean first_update)
{
#if GLIB_CHECK_VERSION(2,0,0)
m->busy = TRUE;
g_thread_create(get_fsusage_thread, m, FALSE, NULL);
g_thread_new("get_fsusage", get_fsusage_thread, m);
#else
gkrellm_sys_fs_get_fsusage(m, m->directory);
#endif
@ -1863,7 +1863,7 @@ run_sensors_thread(void)
if (thread_busy)
return;
thread_busy = TRUE;
g_thread_create(read_sensors, NULL, FALSE, NULL);
g_thread_new("read_sensors", read_sensors, NULL);
#else
read_sensors(NULL);
#endif

View File

@ -352,6 +352,7 @@ libgkrellm.a: win32-libgkrellm.o
# Checks if the build environment is ok
check_env:
$(PKG_CONFIG) --atleast-version=2.32 glib-2.0
$(PKG_CONFIG) --atleast-version=2.4 gtk+-2.0
%.o: %.c

View File

@ -1967,7 +1967,7 @@ gkrellm_client_mode_connect_thread(void)
if (client_mode_thread_busy || !_GK.client_mode)
return;
client_mode_thread_busy = TRUE;
g_thread_create(client_mode_connect_thread, NULL, FALSE, NULL);
g_thread_new("client_mode_connect", client_mode_connect_thread, NULL);
}

View File

@ -479,7 +479,7 @@ update_clock(void)
chime = g_new0(ChimeData, 1);
chime -> command = g_strdup(hour_chime_command);
chime -> count = loop_chime_enable ? ptm->tm_hour : 1;
g_thread_create(chime_func, chime, FALSE, NULL);
g_thread_new("chime", chime_func, chime);
}
}
else
@ -491,7 +491,7 @@ update_clock(void)
chime = g_new0(ChimeData, 1);
chime -> command = g_strdup(quarter_chime_command);
chime -> count = 1;
g_thread_create(chime_func, chime, FALSE, NULL);
g_thread_new("chime", chime_func, chime);
}
}
}

View File

@ -528,7 +528,7 @@ close_tray(FSmon *fs)
if (*close_target)
{
cdrom_thread_busy = TRUE;
g_thread_create(close_cdrom_thread, close_target, FALSE, NULL);
g_thread_new("close_cdrom", close_cdrom_thread, close_target);
}
}
}
@ -562,7 +562,7 @@ eject_tray(FSmon *fs)
if (*eject_target)
{
cdrom_thread_busy = TRUE;
g_thread_create(eject_cdrom_thread, eject_target, FALSE, NULL);
g_thread_new("eject_cdrom", eject_cdrom_thread, eject_target);
}
}
}
@ -797,7 +797,7 @@ fs_update(void)
else if (!fs->busy)
{
fs->busy = TRUE;
g_thread_create(get_fsusage_thread, fs, FALSE, NULL);
g_thread_new("get_fsusage", get_fsusage_thread, fs);
}
fs->krell_factor = fs->blocks > 2097152 ? 1024 : 1;
}

View File

@ -748,7 +748,7 @@ cb_list_button(GkrellmDecalbutton *button)
in->tcp_save_list = g_list_append(in->tcp_save_list, tcp_save);
}
}
g_thread_create(get_connection_string_thread, in, FALSE, NULL);
g_thread_new("get_connection_string", get_connection_string_thread, in);
}
static gint

View File

@ -2408,8 +2408,8 @@ update_mail(void)
if (remote_check && !mbox->busy && mbox->check_func)
{
mbox->busy = TRUE;
mbox->thread = g_thread_create(mail_check_thread,
mbox, FALSE, NULL);
mbox->thread = g_thread_new("mail_check",
mail_check_thread, mbox);
}
else if ( (_GK.debug_level & DEBUG_MAIL)
&& remote_check && mbox->busy

View File

@ -2090,7 +2090,6 @@ main(gint argc, gchar **argv)
#ifdef ENABLE_NLS
gtk_set_locale();
#endif
g_thread_init(NULL);
gtk_init(&argc, &argv); /* Will call gdk_init() */
gkrellm_log_init();
gtk_widget_push_colormap(gdk_rgb_get_colormap());

View File

@ -227,7 +227,7 @@ run_sensors_thread(void)
if (thread_busy)
return;
thread_busy = TRUE;
g_thread_create(read_sensors_thread, NULL, FALSE, NULL);
g_thread_new("read_sensors", read_sensors_thread, NULL);
}
/* Sort so that sensors are ordered: temp, fan, voltage.