Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added type enet_uint64 and changed the methods that uses the new type. #44

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions include/enet/enet.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,11 @@ ENET_API ENetVersion enet_linked_version (void);
Returns the wall-time in milliseconds. Its initial value is unspecified
unless otherwise set.
*/
ENET_API enet_uint32 enet_time_get (void);
ENET_API enet_uint64 enet_time_get (void);
/**
Sets the current wall-time in milliseconds.
*/
ENET_API void enet_time_set (enet_uint32);
ENET_API void enet_time_set (enet_uint64);

/** @defgroup socket ENet socket functions
@{
Expand All @@ -493,7 +493,7 @@ ENET_API ENetSocket enet_socket_accept (ENetSocket, ENetAddress *);
ENET_API int enet_socket_connect (ENetSocket, const ENetAddress *);
ENET_API int enet_socket_send (ENetSocket, const ENetAddress *, const ENetBuffer *, size_t);
ENET_API int enet_socket_receive (ENetSocket, ENetAddress *, ENetBuffer *, size_t);
ENET_API int enet_socket_wait (ENetSocket, enet_uint32 *, enet_uint32);
ENET_API int enet_socket_wait (ENetSocket, enet_uint32 *, enet_uint64);
ENET_API int enet_socket_set_option (ENetSocket, ENetSocketOption, int);
ENET_API int enet_socket_get_option (ENetSocket, ENetSocketOption, int *);
ENET_API int enet_socket_shutdown (ENetSocket, ENetSocketShutdown);
Expand Down Expand Up @@ -554,7 +554,7 @@ ENET_API int enet_host_compress_with_range_coder (ENetHost * host);
ENET_API void enet_host_channel_limit (ENetHost *, size_t);
ENET_API void enet_host_bandwidth_limit (ENetHost *, enet_uint32, enet_uint32);
extern void enet_host_bandwidth_throttle (ENetHost *);
extern enet_uint32 enet_host_random_seed (void);
extern enet_uint64 enet_host_random_seed (void);

ENET_API int enet_peer_send (ENetPeer *, enet_uint8, ENetPacket *);
ENET_API ENetPacket * enet_peer_receive (ENetPeer *, enet_uint8 * channelID);
Expand Down
6 changes: 4 additions & 2 deletions include/enet/types.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
/**
/**
@file types.h
@brief type definitions for ENet
*/
#ifndef __ENET_TYPES_H__
#define __ENET_TYPES_H__

#include <stdint.h>

typedef unsigned char enet_uint8; /**< unsigned 8-bit type */
typedef unsigned short enet_uint16; /**< unsigned 16-bit type */
typedef unsigned int enet_uint32; /**< unsigned 32-bit type */
typedef uint64_t enet_uint64; /**< unsigned 64-bit type */

#endif /* __ENET_TYPES_H__ */

12 changes: 6 additions & 6 deletions unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ typedef int socklen_t;
#define MSG_NOSIGNAL 0
#endif

static enet_uint32 timeBase = 0;
static enet_uint64 timeBase = 0;

int
enet_initialize (void)
Expand All @@ -69,13 +69,13 @@ enet_deinitialize (void)
{
}

enet_uint32
enet_uint64
enet_host_random_seed (void)
{
return (enet_uint32) time (NULL);
return (enet_uint64) time (NULL);
}

enet_uint32
enet_uint64
enet_time_get (void)
{
struct timeval timeVal;
Expand All @@ -86,7 +86,7 @@ enet_time_get (void)
}

void
enet_time_set (enet_uint32 newTimeBase)
enet_time_set (enet_uint64 newTimeBase)
{
struct timeval timeVal;

Expand Down Expand Up @@ -466,7 +466,7 @@ enet_socketset_select (ENetSocket maxSocket, ENetSocketSet * readSet, ENetSocket
}

int
enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout)
enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint64 timeout)
{
#ifdef HAS_POLL
struct pollfd pollSocket;
Expand Down
16 changes: 8 additions & 8 deletions win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <windows.h>
#include <mmsystem.h>

static enet_uint32 timeBase = 0;
static enet_uint64 timeBase = 0;

int
enet_initialize (void)
Expand Down Expand Up @@ -41,22 +41,22 @@ enet_deinitialize (void)
WSACleanup ();
}

enet_uint32
enet_uint64
enet_host_random_seed (void)
{
return (enet_uint32) timeGetTime ();
return (enet_uint64) timeGetTime ();
}

enet_uint32
enet_uint64
enet_time_get (void)
{
return (enet_uint32) timeGetTime () - timeBase;
return (enet_uint64) timeGetTime () - timeBase;
}

void
enet_time_set (enet_uint32 newTimeBase)
enet_time_set (enet_uint64 newTimeBase)
{
timeBase = (enet_uint32) timeGetTime () - newTimeBase;
timeBase = (enet_uint64) timeGetTime () - newTimeBase;
}

int
Expand Down Expand Up @@ -381,7 +381,7 @@ enet_socketset_select (ENetSocket maxSocket, ENetSocketSet * readSet, ENetSocket
}

int
enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint32 timeout)
enet_socket_wait (ENetSocket socket, enet_uint32 * condition, enet_uint64 timeout)
{
fd_set readSet, writeSet;
struct timeval timeVal;
Expand Down