<commit_before>/* $chaos: memory.h,v 1.2 2002/06/05 18:17:43 per Exp $ */
/* Abstract: Memory operations. */
/* Author: <NAME> <<EMAIL>> */

/* Copyright 2002 chaos development. */
/* Use freely under the terms listed in the file COPYING. */

#ifndef __STORM_IA32_MEMORY_H__
#define __STORM_IA32_MEMORY_H__

#include <storm/types.h>

/* Inlines. */
/* FIXME: These are not all nice. */
static inline void *memory_copy (void *to, void *from, int n)
{
    int ecx, edi, esi;
    
    asm volatile ("cld\n"
                  "rep ; movsl\n"
                  "testb $2, %b4\n"
                  "je 1f\n"
                  "movsw\n"
                  "1: testb $1, %b4\n"
                  "je 2f\n"
                  "movsb\n"
                  "2:"
                  : 
                  "=&c" (ecx), 
                  "=&D" (edi), 
                  "=&S" (esi)
                  :
                  "0" (n / 4),
                  "q" (n),
                  "1" ((long) to),
                  "2" ((long) from)
                  : 
                  "memory");
    
    return (to);
}

static inline void memory_set_uint8 (uint8_t *address, uint8_t c,
                                     unsigned int size)
{
    int ecx, edi;
    
    asm volatile ("cld\n"
                  "rep\n"
                  "stosb"
                  :
                  "=&c" (ecx),
                  "=&D" (edi)
                  : 
                  "a" (c),
                  "1" (address),
                  "0" (size)
                  : 
                  "memory");
}

static inline void memory_set_uint16 (uint16_t *addr, uint16_t c,
                                      unsigned int size)
{
    int d0, d1;

    asm volatile  ("cld\n"
                   "rep\n"
                   "stosw"
                   : 
                   "=&c" (d0),
                   "=&D" (d1)
                   : 
                   "a" (c),
                   "1" (addr),
                   "0" (size)
                   :
                   "memory");
}

static inline void memory_set_uint32 (uint32_t *addr, uint32_t c,
                                      unsigned int size)
{
    int d0, d1;

    asm volatile  ("cld\n"
                   "rep\n"
                   "stosl"
                   : 
                   "=&c" (d0),
                   "=&D" (d1)
                   : 
                   "a" (c),
                   "1" (addr),
                   "0" (size)
                   :
                   "memory");
}

#endif /* !__STORM_IA32_MEMORY_H__ */<commit_msg>Fixed a FIXME<commit_after>/* $chaos: memory.h,v 1.3 2002/06/09 15:04:52 per Exp $ */
/* Abstract: Memory operations. */
/* Author: <NAME> <<EMAIL>> */

/* Copyright 2002 chaos development. */
/* Use freely under the terms listed in the file COPYING. */

#ifndef __STORM_IA32_MEMORY_H__
#define __STORM_IA32_MEMORY_H__

#include <storm/types.h>

/* Inlines. */
static inline void *memory_copy (void *to, void *from, unsigned int size)
{
    int ecx, edi, esi;
    
    asm volatile ("cld\n"
                  "rep ; movsl\n"
                  "testb $2, %b4\n"
                  "je 1f\n"
                  "movsw\n"
                  "1: testb $1, %b4\n"
                  "je 2f\n"
                  "movsb\n"
                  "2:"
                  : 
                  "=&c" (ecx), 
                  "=&D" (edi), 
                  "=&S" (esi)
                  :
                  "0" (n / 4),
                  "q" (n),
                  "1" ((long) to),
                  "2" ((long) from)
                  : 
                  "memory");
    
    return (to);
}

static inline void memory_set_uint8 (uint8_t *address, uint8_t c,
                                     unsigned int size)
{
    int ecx, edi;
    
    asm volatile ("cld\n"
                  "rep\n"
                  "stosb"
                  :
                  "=&c" (ecx),
                  "=&D" (edi)
                  : 
                  "a" (c),
                  "1" (address),
                  "0" (size)
                  : 
                  "memory");
}

static inline void memory_set_uint16 (uint16_t *address, uint16_t c,
                                      unsigned int size)
{
    int ecx, edi;

    asm volatile  ("cld\n"
                   "rep\n"
                   "stosw"
                   : 
                   "=&c" (ecx),
                   "=&D" (edi)
                   : 
                   "a" (c),
                   "1" (address),
                   "0" (size)
                   :
                   "memory");
}

static inline void memory_set_uint32 (uint32_t *address, uint32_t c,
                                      unsigned int size)
{
    int ecx, edi;

    asm volatile  ("cld\n"
                   "rep\n"
                   "stosl"
                   : 
                   "=&c" (ecx),
                   "=&D" (edi)
                   : 
                   "a" (c),
                   "1" (address),
                   "0" (size)
                   :
                   "memory");
}

#endif /* !__STORM_IA32_MEMORY_H__ */
{'fraction_non_alphanumeric': 0.12694045981528787, 'fraction_numerical': 0.024759284731774415, 'mean_word_length': 0.8107435076485237, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4023372', 'n_tokens_mistral': 1719, 'n_tokens_neox': 1506, 'n_words': 369}