glib2: share common code