Skip to content
This repository was archived by the owner on Mar 9, 2020. It is now read-only.

Commit 2ef1b7d

Browse files
committed
Fix bad usage of bswap
1 parent 0d309a8 commit 2ef1b7d

File tree

5 files changed

+14
-340
lines changed

5 files changed

+14
-340
lines changed

configure

-141
Original file line numberDiff line numberDiff line change
@@ -2308,102 +2308,6 @@ ac_config_headers="$ac_config_headers config.h"
23082308

23092309

23102310

2311-
# ===========================================================================
2312-
# http://www.gnu.org/software/autoconf-archive/ax_gcc_builtin.html
2313-
# ===========================================================================
2314-
#
2315-
# SYNOPSIS
2316-
#
2317-
# AX_GCC_BUILTIN(BUILTIN)
2318-
#
2319-
# DESCRIPTION
2320-
#
2321-
# This macro checks if the compiler supports one of GCC's built-in
2322-
# functions; many other compilers also provide those same built-ins.
2323-
#
2324-
# The BUILTIN parameter is the name of the built-in function.
2325-
#
2326-
# If BUILTIN is supported define HAVE_<BUILTIN>. Keep in mind that since
2327-
# builtins usually start with two underscores they will be copied over
2328-
# into the HAVE_<BUILTIN> definition (e.g. HAVE___BUILTIN_EXPECT for
2329-
# __builtin_expect()).
2330-
#
2331-
# The macro caches its result in the ax_cv_have_<BUILTIN> variable (e.g.
2332-
# ax_cv_have___builtin_expect).
2333-
#
2334-
# The macro currently supports the following built-in functions:
2335-
#
2336-
# __builtin_assume_aligned
2337-
# __builtin_bswap32
2338-
# __builtin_bswap64
2339-
# __builtin_choose_expr
2340-
# __builtin___clear_cache
2341-
# __builtin_clrsb
2342-
# __builtin_clrsbl
2343-
# __builtin_clrsbll
2344-
# __builtin_clz
2345-
# __builtin_clzl
2346-
# __builtin_clzll
2347-
# __builtin_complex
2348-
# __builtin_constant_p
2349-
# __builtin_ctz
2350-
# __builtin_ctzl
2351-
# __builtin_ctzll
2352-
# __builtin_expect
2353-
# __builtin_ffs
2354-
# __builtin_ffsl
2355-
# __builtin_ffsll
2356-
# __builtin_fpclassify
2357-
# __builtin_huge_val
2358-
# __builtin_huge_valf
2359-
# __builtin_huge_vall
2360-
# __builtin_inf
2361-
# __builtin_infd128
2362-
# __builtin_infd32
2363-
# __builtin_infd64
2364-
# __builtin_inff
2365-
# __builtin_infl
2366-
# __builtin_isinf_sign
2367-
# __builtin_nan
2368-
# __builtin_nand128
2369-
# __builtin_nand32
2370-
# __builtin_nand64
2371-
# __builtin_nanf
2372-
# __builtin_nanl
2373-
# __builtin_nans
2374-
# __builtin_nansf
2375-
# __builtin_nansl
2376-
# __builtin_object_size
2377-
# __builtin_parity
2378-
# __builtin_parityl
2379-
# __builtin_parityll
2380-
# __builtin_popcount
2381-
# __builtin_popcountl
2382-
# __builtin_popcountll
2383-
# __builtin_powi
2384-
# __builtin_powif
2385-
# __builtin_powil
2386-
# __builtin_prefetch
2387-
# __builtin_trap
2388-
# __builtin_types_compatible_p
2389-
# __builtin_unreachable
2390-
#
2391-
# Unsuppored built-ins will be tested with an empty parameter set and the
2392-
# result of the check might be wrong or meaningless so use with care.
2393-
#
2394-
# LICENSE
2395-
#
2396-
# Copyright (c) 2013 Gabriele Svelto <[email protected]>
2397-
#
2398-
# Copying and distribution of this file, with or without modification, are
2399-
# permitted in any medium without royalty provided the copyright notice
2400-
# and this notice are preserved. This file is offered as-is, without any
2401-
# warranty.
2402-
2403-
#serial 2
2404-
2405-
2406-
24072311

24082312
# Checks for programs.
24092313
ac_ext=c
@@ -4593,51 +4497,6 @@ done
45934497

45944498

45954499

4596-
4597-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_bswap32" >&5
4598-
$as_echo_n "checking for __builtin_bswap32... " >&6; }
4599-
if ${ax_cv_have___builtin_bswap32+:} false; then :
4600-
$as_echo_n "(cached) " >&6
4601-
else
4602-
4603-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
4604-
/* end confdefs.h. */
4605-
4606-
int
4607-
main ()
4608-
{
4609-
4610-
__builtin_bswap32(0)
4611-
4612-
;
4613-
return 0;
4614-
}
4615-
_ACEOF
4616-
if ac_fn_c_try_link "$LINENO"; then :
4617-
ax_cv_have___builtin_bswap32=yes
4618-
else
4619-
ax_cv_have___builtin_bswap32=no
4620-
fi
4621-
rm -f core conftest.err conftest.$ac_objext \
4622-
conftest$ac_exeext conftest.$ac_ext
4623-
4624-
fi
4625-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_have___builtin_bswap32" >&5
4626-
$as_echo "$ax_cv_have___builtin_bswap32" >&6; }
4627-
4628-
if test yes = $ax_cv_have___builtin_bswap32; then :
4629-
4630-
cat >>confdefs.h <<_ACEOF
4631-
#define HAVE___BUILTIN_BSWAP32 1
4632-
_ACEOF
4633-
4634-
fi
4635-
4636-
4637-
4638-
4639-
4640-
46414500
ac_config_files="$ac_config_files Makefile"
46424501

46434502
cat >confcache <<\_ACEOF

configure.ac

-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ AC_CONFIG_HEADERS([config.h])
55

66
m4_include([m4_ax_check_openssl.m4])
77
m4_include([m4_ax_check_zlib.m4])
8-
m4_include([m4-ax_gcc_builtin.m4])
98

109
# Checks for programs.
1110
AC_PROG_CC
@@ -88,8 +87,6 @@ AC_FUNC_MALLOC
8887
AC_FUNC_REALLOC
8988
AC_CHECK_FUNCS([alarm endpwent memset memmove mkdir select socket strdup strndup uname])
9089

91-
AX_GCC_BUILTIN(__builtin_bswap32)
92-
9390
AC_SUBST(EXTRA_LIBS)
9491
AC_SUBST(EXTRA_OBJECTS)
9592
AC_CONFIG_FILES([Makefile])

m4-ax_gcc_builtin.m4

-168
This file was deleted.

mtproto-client.c

-20
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
#include <signal.h>
3434
#include <unistd.h>
3535
#include <fcntl.h>
36-
#if defined(__FreeBSD__) || defined(__OpenBSD__)
37-
#include <sys/endian.h>
38-
#endif
3936
#include <sys/types.h>
4037
#ifdef WIN32
4138
#include <winsock2.h>
@@ -67,14 +64,6 @@
6764
#include "auto.h"
6865
#include "tgl-methods-in.h"
6966

70-
#if defined(__FreeBSD__)
71-
#define __builtin_bswap32(x) bswap32(x)
72-
#endif
73-
74-
#if defined(__OpenBSD__)
75-
#define __builtin_bswap32(x) __swap32gen(x)
76-
#endif
77-
7867
#include "mtproto-common.h"
7968

8069
#define MAX_NET_RES (1L << 16)
@@ -83,15 +72,6 @@
8372
static long long generate_next_msg_id (struct tgl_state *TLS, struct tgl_dc *DC, struct tgl_session *S);
8473
static double get_server_time (struct tgl_dc *DC);
8574

86-
#if !defined(HAVE___BUILTIN_BSWAP32) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
87-
static inline unsigned __builtin_bswap32(unsigned x) {
88-
return ((x << 24) & 0xff000000 ) |
89-
((x << 8) & 0x00ff0000 ) |
90-
((x >> 8) & 0x0000ff00 ) |
91-
((x >> 24) & 0x000000ff );
92-
}
93-
#endif
94-
9575
// for statistic only
9676
static int total_packets_sent;
9777
static long long total_data_sent;

0 commit comments

Comments
 (0)