Adobe Flash C++ Compiler (FlasCC)

A complete BSD-like C/C++ development environment with a GCC based cross-compiler capable of targeting the Adobe Flash Runtime.

AVM2.h

The AVM2.h header file contains various low-level FlasCC-specific utility functions and macros.

Function Description

__avm2_apply_args

#define __avm2_apply_args()

Returns a pointer to data describing how to perform a call with the same arguments as were passed to the current function.

For more information, see http://tigcc.ticalc.org/doc/gnuexts.html#SEC67

__avm2_apply

#define __avm2_apply(function, arguments, size)

Invokes function with a copy of the parameters described by arguments and size.

For more information, see http://tigcc.ticalc.org/doc/gnuexts.html#SEC67

Parameters:

  • function - The function to be invoked.
  • arguments - The arguments to be passed. This should be the value returned by __avm2_apply_args().
  • size - The number of bytes in the stack argument data.

__avm2_return

#define __avm2_return(result)

Returns the value described by result from the containing function.

Parameters:

  • result - The value returned by __avm2_apply.

__builtin_va_arg_pack

#define __builtin_va_arg_pack

Error. Not supported in FlasCC.

__builtin_va_arg_pack_len

#define __builtin_va_arg_pack_len

Error. Not supported in FlasCC.

__builtin_apply_args

__avm2_apply_args overrides __builtin_apply_args.

For more information, see http://tigcc.ticalc.org/doc/gnuexts.html#SEC67.

__builtin_apply

__avm2_apply overrides __builtin_apply.

For more information, see http://tigcc.ticalc.org/doc/gnuexts.html#SEC67.

__builtin_return

__avm2_return overrides __builtin_return.

For more information, see http://tigcc.ticalc.org/doc/gnuexts.html#SEC67.

avm2_locked_id

unsigned avm2_locked_id(unsigned *mtx);

Returns the id of the lock owner. Low-level concurrency primitives -- expect hangs or worse if not used properly. Non-recursive mutexes.

Parameters:

  • mtx - ID of lock owner or 0.

avm2_lock

void avm2_lock(unsigned *mtx);

Low-level concurrency primitives -- expect hangs or worse if not used properly. Non-recursive mutexes.

Parameters:

  • mtx - lock with thread id.

avm2_lock_id

void avm2_lock_id(unsigned *mtx, unsigned id);

Low-level concurrency primitives -- expect hangs or worse if not used properly. Non-recursive mutexes.

Parameters:

  • mtx - lock with any non-0 value.
  • id - lock owner id.

avm2_unlock

void avm2_unlock(unsigned *mtx);

Super low-level concurrency primitives -- expect hangs or worse if not used properly. Non-recursive mutexes.

Parameters:

  • mtx - unlock.
Address token-based conditions

avm2_msleep

int avm2_msleep(void *addr, unsigned *mtx, int timo);

Waits for addr to be woken for timo milliseconds (or forever if timo==0). Releases mutex on entry, re-acquired before return 0 on timeout, non-zero on wake.

Parameters:

  • addr - Sleep on address.
  • mtx - Must be locked on entry.
  • timo - Number of milliseconds this function waits for addr to be woken (forever if timo==0).

avm2_wake

int avm2_wake(void *addr);

Wake any threads msleeping on addr, returns non-zero if a thread was woken.

Parameters:

  • addr - Address pointing to sleeping threads.

Example Usage:

See the 09_pthreads sample

avm2_wake_one

int avm2_wake_one(void *addr);

Wake zero (if none msleeping on addr) or one threads msleeping on addr, returns non-zero if any thread was woken.

Parameters:

  • addr - Address pointing to sleeping threads.

avm2_thr_impersonate

void *avm2_thr_impersonate(long tid, void *(*proc)(void *), void *arg);

Call proc(arg) while impersonating the thread specified by tid.

Parameters:

  • tid - Long containing the thread to impersonate.
  • proc - The function pointer.
  • arg - The data to pass to the function pointer.

avm2_ui_thunk

void *avm2_ui_thunk(void *(*proc)(void *), void *arg);

Call proc(arg) on the UI Worker as calling thread.

Parameters:

  • proc - The function pointer.
  • arg - The data to pass to the function pointer.

avm2_is_ui_worker

int avm2_is_ui_worker();

Returns non-zero if running on the UI Worker.

avm2_wait_for_ui_frame

int avm2_wait_for_ui_frame(int timo);

Wait for a frame event or until timeout. Returns 0 on timeout.

Parameters:

  • timo - A timeout interval, in milliseconds.

avm2_self_lock

void avm2_self_lock();

Lock this thread to this Worker -- recursive OK.

avm2_self_unlock

void avm2_self_unlock();

Unlock this thread.

avm2_self_msleep

int avm2_self_msleep(void *addr, int timo);

Works like avm2_msleep with mtx being "self" -- "self" must be locked using avm2_self_lock.

Parameters:

  • addr - Sleep on address.
  • timo - Number of milliseconds this function waits for addr to be woken (forever if timo==0).

Example Usage:

See the 09_pthreads sample

avm2_tramp_alloc

void *avm2_tramp_alloc(void *funPtr, int sret, void *arg0, void *arg1);

Trampoline support. For more information, see sdk/usr/share/avm2_tramp.cpp.

Parameters:

  • funPtr - Function pointer.
  • sret - Size of the structure return type for POD or the negative size of the structure for non-POD. Must be zero for a non-structure return type.
  • arg0 - First argument.
  • arg1 - Second argument.

avm2_tramp_free

void avm2_tramp_free(void *trampFunPtr);

Trampoline support. For more information, see sdk/usr/share/avm2_tramp.cpp.

Parameters:

  • trampFunPtr - Function pointer to be freed.