<commit_before>/** \ingroup rpmio
 * \file rpmio/rpmsw.c
 */

#include "system.h"
#include <rpmsw.h>
#include "debug.h"

#if defined(__LCLINT__)
/*@-exportheader@*/
extern int nanosleep(const struct timespec *__requested_time,
		/*@out@*/ /*@null@*/ struct timespec *__remaining)
	/*@globals errno @*/
	/*@modifies *__remaining, errno @*/;
/*@=exportheader@*/
#endif

/*@unchecked@*/
static rpmtime_t rpmsw_overhead = 0;

/*@unchecked@*/
static rpmtime_t rpmsw_cycles = 1;

/*@unchecked@*/
static int rpmsw_type = 0;

/*@unchecked@*/
static int rpmsw_initialized = 0;

#if defined(__i386__)
/* Swiped from glibc-2.3.2 sysdeps/i386/i686/hp-timing.h */

#define	HP_TIMING_ZERO(Var)	(Var) = (0)
#define	HP_TIMING_NOW(Var)	__asm__ __volatile__ ("rdtsc" : "=A" (Var))

/* It's simple arithmetic for us.  */
#define	HP_TIMING_DIFF(Diff, Start, End)	(Diff) = ((End) - (Start))

/* We have to jump through hoops to get this correctly implemented.  */
#define HP_TIMING_ACCUM(Sum, Diff) \
  do {									      \
    char __not_done;							      \
    hp_timing_t __oldval = (Sum);					      \
    hp_timing_t __diff = (Diff) - GL(dl_hp_timing_overhead);		      \
    do									      \
      {									      \
	hp_timing_t __newval = __oldval + __diff;			      \
	int __temp0, __temp1;						      \
	__asm__ __volatile__ ("xchgl %4, %%ebx\n\t"			      \
			      "lock; cmpxchg8b %1\n\t"			      \
			      "sete %0\n\t"				      \
			      "movl %4, %%ebx"				      \
			      : "=q" (__not_done), "=m" (Sum),		      \<commit_msg>please use Linux-specific i386 assembly stuff under Linux only<commit_after>/** \ingroup rpmio
 * \file rpmio/rpmsw.c
 */

#include "system.h"
#include <rpmsw.h>
#include "debug.h"

#if defined(__LCLINT__)
/*@-exportheader@*/
extern int nanosleep(const struct timespec *__requested_time,
		/*@out@*/ /*@null@*/ struct timespec *__remaining)
	/*@globals errno @*/
	/*@modifies *__remaining, errno @*/;
/*@=exportheader@*/
#endif

/*@unchecked@*/
static rpmtime_t rpmsw_overhead = 0;

/*@unchecked@*/
static rpmtime_t rpmsw_cycles = 1;

/*@unchecked@*/
static int rpmsw_type = 0;

/*@unchecked@*/
static int rpmsw_initialized = 0;

#if defined(__linux__) && defined(__i386__)
/* Swiped from glibc-2.3.2 sysdeps/i386/i686/hp-timing.h */

#define	HP_TIMING_ZERO(Var)	(Var) = (0)
#define	HP_TIMING_NOW(Var)	__asm__ __volatile__ ("rdtsc" : "=A" (Var))

/* It's simple arithmetic for us.  */
#define	HP_TIMING_DIFF(Diff, Start, End)	(Diff) = ((End) - (Start))

/* We have to jump through hoops to get this correctly implemented.  */
#define HP_TIMING_ACCUM(Sum, Diff) \
  do {									      \
    char __not_done;							      \
    hp_timing_t __oldval = (Sum);					      \
    hp_timing_t __diff = (Diff) - GL(dl_hp_timing_overhead);		      \
    do									      \
      {									      \
	hp_timing_t __newval = __oldval + __diff;			      \
	int __temp0, __temp1;						      \
	__asm__ __volatile__ ("xchgl %4, %%ebx\n\t"			      \
			      "lock; cmpxchg8b %1\n\t"			      \
			      "sete %0\n\t"				      \
			      "movl %4, %%ebx"				      \
			      : "=q" (__not_done), "=m" (Sum),		      \
{'fraction_non_alphanumeric': 0.15890850722311398, 'fraction_numerical': 0.01637239165329053, 'mean_word_length': 2.424175824175824, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5139838', 'n_tokens_mistral': 1444, 'n_tokens_neox': 1265, 'n_words': 269}