fixed code for an old gcc compiler that couldn't recognize x86 inline assembly containing the rep prefix on the same line as the movXX and stoXX instructions.

This commit is contained in:
hyung-hwan 2014-10-17 15:37:36 +00:00
parent a842cf0767
commit e7287cb52c
3 changed files with 20 additions and 9 deletions

View File

@ -15,6 +15,8 @@
#include <signal.h>
#include <locale.h>
#include <stdio.h> /* TODO: remove this header file */
#if defined(_WIN32)
# include <winsock2.h>
# include <windows.h>
@ -377,6 +379,7 @@ static int daemonize (int devnull)
int xxxx (void* ctx, qse_env_char_t** envir)
{
/* NOTE: this is for experiment only */
extern char** environ;
char buf[1000];
char* cl;

View File

@ -133,14 +133,14 @@ void* qse_memcpy (void* dst, const void* src, qse_size_t n)
__asm__ volatile (
"cld\n\t"
"rep movsl\n"
"rep\n\tmovsl\n"
: /* no output */
:"D" (dst), "S" (src), "c" (n >> 2) /* input: %edi = d, %esi = src, %ecx = n / 8 */
:"memory"
);
__asm__ volatile (
"rep movsb\n"
"rep\n\tmovsb\n"
: /* no output */
:"c" (n & 3) /* %rcx = n % 8, use existing %edi and %esi */
:"memory", "%edi", "%esi"
@ -348,7 +348,7 @@ void* qse_memset (void* dst, int val, qse_size_t n)
}
__asm__ volatile (
"rep stosl\n"
"rep\n\tstosl\n"
:"=D" (d) /* output: d = %edi */
:"0" (d), "a" (dw), "c" (n >> 2) /* input: %edi = d, %eax = dw, %ecx = n / 4 */
:"memory"
@ -356,7 +356,7 @@ void* qse_memset (void* dst, int val, qse_size_t n)
}
__asm__ volatile (
"rep stosb\n"
"rep\n\tstosb\n"
: /* no output */
:"D" (d), "a" (val), "c" (n & 3) /* input: %edi = d, %eax = src, %ecx = n % 4 */
:"memory"

View File

@ -534,7 +534,7 @@ static QSE_INLINE qse_ssize_t __send_file_ssl (
qse_mchar_t buf[MAX_SEND_SIZE];
qse_ssize_t ret;
qse_foff_t foff;
SSL* out = (SSL*)xout;
SSL* out = HANDLE_TO_SSL((qse_sck_hnd_t)xout);
if (offset && (foff = qse_fio_seek (HANDLE_TO_FIO(in_fd), *offset, QSE_FIO_BEGIN)) != *offset)
{
@ -1118,14 +1118,15 @@ static int peer_open (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
/* -------------------------------------------------------------------- */
httpd_xtn_t* xtn;
qse_skad_t connaddr, bindaddr;
int connaddrsize, bindaddrsize;
int connected = 1;
qse_sck_hnd_t fd = QSE_INVALID_SCKHND;
SSL* ssl = QSE_NULL;
httpd_xtn_t* xtn;
xtn = (httpd_xtn_t*) qse_httpd_getxtn (httpd);
#if defined(HAVE_SSL)
SSL* ssl = QSE_NULL;
#endif
#if defined(_WIN32)
unsigned long cmd;
@ -1136,6 +1137,8 @@ static int peer_open (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
#else
int flag;
#endif
xtn = (httpd_xtn_t*) qse_httpd_getxtn (httpd);
/* turn off internally used bits */
peer->flags &= ~QSE_HTTPD_PEER_ALL_INTERNALS;
@ -1371,6 +1374,7 @@ static int is_peer_socket_connected (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
static int is_peer_connected_securely (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
{
#if defined(HAVE_SSL)
int ret = SSL_connect (HANDLE_TO_SSL(peer->handle2));
if (ret <= 0)
{
@ -1387,6 +1391,10 @@ static int is_peer_connected_securely (qse_httpd_t* httpd, qse_httpd_peer_t* pee
}
}
return 1;
#else
qse_httpd_seterrnum (httpd, QSE_HTTPD_ENOIMPL);
return -1;
#endif
}
static int peer_connected (qse_httpd_t* httpd, qse_httpd_peer_t* peer)
@ -2204,7 +2212,7 @@ static qse_ssize_t client_sendfile (
{
if (client->status & QSE_HTTPD_CLIENT_SECURE)
{
return __send_file_ssl (httpd, HANDLE_TO_SSL(client->handle2), handle, offset, count);
return __send_file_ssl (httpd, (void*)client->handle2, handle, offset, count);
}
else
{