Move _xcb_set_fd_flags to xcb_conn.c and make it static. xcb_util.c now has only public functions.

This commit is contained in:
Jamey Sharp 2006-02-24 01:50:48 -08:00
parent 67b2649dc4
commit bae98d3604
3 changed files with 17 additions and 28 deletions

View File

@ -32,10 +32,24 @@
#include <stdlib.h> #include <stdlib.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/select.h> #include <sys/select.h>
#include <sys/fcntl.h>
#include "xcb.h" #include "xcb.h"
#include "xcbint.h" #include "xcbint.h"
static int set_fd_flags(const int fd)
{
long flags = fcntl(fd, F_GETFL, 0);
if(flags == -1)
return 0;
flags |= O_NONBLOCK;
if(fcntl(fd, F_SETFL, flags) == -1)
return 0;
if(fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
return 0;
return 1;
}
static int write_setup(XCBConnection *c, XCBAuthInfo *auth_info) static int write_setup(XCBConnection *c, XCBAuthInfo *auth_info)
{ {
static const char pad[3]; static const char pad[3];
@ -147,7 +161,7 @@ XCBConnection *XCBConnectToFD(int fd, XCBAuthInfo *auth_info)
c->fd = fd; c->fd = fd;
if(!( if(!(
_xcb_set_fd_flags(fd) && set_fd_flags(fd) &&
pthread_mutex_init(&c->iolock, 0) == 0 && pthread_mutex_init(&c->iolock, 0) == 0 &&
_xcb_in_init(&c->in) && _xcb_in_init(&c->in) &&
_xcb_out_init(&c->out) && _xcb_out_init(&c->out) &&

View File

@ -28,7 +28,6 @@
#include <assert.h> #include <assert.h>
#include <sys/select.h> #include <sys/select.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/fcntl.h>
#include <sys/un.h> #include <sys/un.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <netdb.h> #include <netdb.h>
@ -197,22 +196,3 @@ int XCBSync(XCBConnection *c, XCBGenericError **e)
free(reply); free(reply);
return reply != 0; return reply != 0;
} }
/* The functions beyond this point still use only public interfaces,
* but are not themselves part of the public interface. So their
* prototypes are in xcbint.h. */
#include "xcbint.h"
int _xcb_set_fd_flags(const int fd)
{
long flags = fcntl(fd, F_GETFL, 0);
if(flags == -1)
return 0;
flags |= O_NONBLOCK;
if(fcntl(fd, F_SETFL, flags) == -1)
return 0;
if(fcntl(fd, F_SETFD, FD_CLOEXEC) == -1)
return 0;
return 1;
}

View File

@ -37,6 +37,8 @@ enum workarounds {
WORKAROUND_GLX_GET_FB_CONFIGS_BUG WORKAROUND_GLX_GET_FB_CONFIGS_BUG
}; };
#define XCB_PAD(i) (-(i) & 3)
/* xcb_list.c */ /* xcb_list.c */
typedef struct _xcb_list _xcb_list; typedef struct _xcb_list _xcb_list;
@ -68,13 +70,6 @@ void *_xcb_map_get(_xcb_map *q, unsigned int key);
void *_xcb_map_remove(_xcb_map *q, unsigned int key); void *_xcb_map_remove(_xcb_map *q, unsigned int key);
/* xcb_util.c */
#define XCB_PAD(i) (-(i) & 3)
int _xcb_set_fd_flags(const int fd);
/* xcb_out.c */ /* xcb_out.c */
typedef struct _xcb_out { typedef struct _xcb_out {