Click here to Skip to main content
15,879,095 members
Articles / Programming Languages / C

How to develop a virtual disk for Windows

,
Rate me:
Please Sign up or sign in to vote.
4.99/5 (98 votes)
15 Feb 2010CPOL10 min read 195.2K   8.2K   335  
This article is oriented to Windows-developers and considers how to create virtual disk in Windows system.
// Currently, SUN CC requires object file

#if defined (__GNUC__)

/*
**  int _STLP_atomic_exchange (__stl_atomic_t *pvalue, __stl_atomic_t value)
*/
 
# ifdef __sparc_v9__

#  ifdef __arch64__

#   define _STLP_EXCH_ASM  asm volatile ("casx [%3], %4, %0 ;  membar  #LoadLoad | #LoadStore " : \
                   "=r" (_L_value2), "=m" (*_L_pvalue1) : \
                   "m" (*_L_pvalue1), "r" (_L_pvalue1), "r" (_L_value1), "0" (_L_value2) )

#  else /* __arch64__ */

#   define _STLP_EXCH_ASM  asm volatile ("cas [%3], %4, %0" : \
                   "=r" (_L_value2), "=m" (*_L_pvalue1) : \
                   "m" (*_L_pvalue1), "r" (_L_pvalue1), "r" (_L_value1), "0" (_L_value2) )
#  endif

# else /* __sparc_v9__ */

#  define _STLP_EXCH_ASM asm volatile ("swap [%3], %0 " : \
                                       "=r" (_L_value2), "=m" (*_L_pvalue1) : \
                                       "m" (*_L_pvalue1), "r" (_L_pvalue1),  "0" (_L_value2) )
# endif


#  define _STLP_ATOMIC_EXCHANGE(__pvalue1, __value2) \
 ({  register volatile __stl_atomic_t *_L_pvalue1 = __pvalue1; \
     register __stl_atomic_t _L_value1, _L_value2 =  __value2 ; \
     do { _L_value1 = *_L_pvalue1; _STLP_EXCH_ASM; } while ( _L_value1 != _L_value2 ) ; \
     _L_value1; })

#  define _STLP_ATOMIC_INCREMENT(__pvalue1) \
 {  register volatile __stl_atomic_t *_L_pvalue1 = __pvalue1; \
    register __stl_atomic_t _L_value1, _L_value2; \
    do { _L_value1 = *_L_pvalue1;  _L_value2 = _L_value1+1; _STLP_EXCH_ASM; } while ( _L_value1 != _L_value2 ) ; }

#  define _STLP_ATOMIC_DECREMENT(__pvalue1) \
 {  register volatile __stl_atomic_t *_L_pvalue1 = __pvalue1; \
    register __stl_atomic_t _L_value1, _L_value2; \
    do { _L_value1 = *_L_pvalue1;  _L_value2 = _L_value1-1; _STLP_EXCH_ASM; } while ( _L_value1 != _L_value2 ) ; }

# elif ! defined (_STLP_NO_EXTERN_INLINE) 

extern "C" __stl_atomic_t _STLP_atomic_exchange(__stl_atomic_t * __x, __stl_atomic_t __v);
extern "C" void _STLP_atomic_decrement(__stl_atomic_t* i);
extern "C" void _STLP_atomic_increment(__stl_atomic_t* i);

#  define _STLP_ATOMIC_INCREMENT(__x)           _STLP_atomic_increment((__stl_atomic_t*)__x)
#  define _STLP_ATOMIC_DECREMENT(__x)           _STLP_atomic_decrement((__stl_atomic_t*)__x)
#  define _STLP_ATOMIC_EXCHANGE(__x, __y)       _STLP_atomic_exchange((__stl_atomic_t*)__x, (__stl_atomic_t)__y)

# endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Chief Technology Officer Apriorit Inc.
United States United States
ApriorIT is a software research and development company specializing in cybersecurity and data management technology engineering. We work for a broad range of clients from Fortune 500 technology leaders to small innovative startups building unique solutions.

As Apriorit offers integrated research&development services for the software projects in such areas as endpoint security, network security, data security, embedded Systems, and virtualization, we have strong kernel and driver development skills, huge system programming expertise, and are reals fans of research projects.

Our specialty is reverse engineering, we apply it for security testing and security-related projects.

A separate department of Apriorit works on large-scale business SaaS solutions, handling tasks from business analysis, data architecture design, and web development to performance optimization and DevOps.

Official site: https://www.apriorit.com
Clutch profile: https://clutch.co/profile/apriorit
This is a Organisation

33 members

Written By
Team Leader ApriorIT
Ukraine Ukraine
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions